add new preventDefault property for Konva.Shape

This commit is contained in:
Anton Lavrenov
2016-08-21 12:59:25 +07:00
parent 8eb373adeb
commit 1050dd5bb5
3 changed files with 31 additions and 4 deletions

View File

@@ -4,6 +4,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Not released][Not released]
## [1.1.0][2016-08-21]
## Added
- new property of `Konva.Shape` - `preventDefault`.
## [1.0.3][2016-08-14]
### Fixed

View File

@@ -465,6 +465,28 @@
Konva.Factory.addGetterSetter(Konva.Shape, 'strokeWidth', 2);
/**
* get/set preventDefault
* By default all shapes will prevent default behaviour
* of a browser on a pointer move or tap.
* that will prevent native scrolling when you are trying to drag&drop a shape
* but sometimes you may need to enable default actions
* in that case you can set the property to false
* @name preventDefault
* @method
* @memberof Konva.Shape.prototype
* @param {Number} preventDefault
* @returns {Number}
* @example
* // get stroke width
* var strokeWidth = shape.strokeWidth();
*
* // set stroke width
* shape.strokeWidth();
*/
Konva.Factory.addGetterSetter(Konva.Shape, 'preventDefault', true);
/**
* get/set stroke width
* @name strokeWidth

View File

@@ -564,7 +564,7 @@
shape._fireAndBubble(TOUCHSTART, {evt: evt});
// only call preventDefault if the shape is listening for events
if (shape.isListening() && evt.preventDefault) {
if (shape.isListening() && shape.preventDefault() && evt.preventDefault) {
evt.preventDefault();
}
}
@@ -600,7 +600,7 @@
}
}
// only call preventDefault if the shape is listening for events
if (shape.isListening() && evt.preventDefault) {
if (shape.isListening() && shape.preventDefault() && evt.preventDefault) {
evt.preventDefault();
}
}
@@ -624,14 +624,14 @@
if (shape && shape.isListening()) {
shape._fireAndBubble(TOUCHMOVE, {evt: evt});
// only call preventDefault if the shape is listening for events
if (shape.isListening() && evt.preventDefault) {
if (shape.isListening() && shape.preventDefault() && evt.preventDefault) {
evt.preventDefault();
}
}
this._fire(CONTENT_TOUCHMOVE, {evt: evt});
}
if(dd) {
if (Konva.isDragging()) {
if (Konva.isDragging() && Konva.DD.node.preventDefault()) {
evt.preventDefault();
}
}