mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
add new preventDefault
property for Konva.Shape
This commit is contained in:
@@ -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
|
||||
|
22
src/Shape.js
22
src/Shape.js
@@ -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
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user