mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
changed listen property to listening, listen() to setListening(), and isListening() to getListening() for consistency
This commit is contained in:
34
src/Node.js
34
src/Node.js
@@ -11,7 +11,7 @@
|
||||
Kinetic.Node = function(config) {
|
||||
this.defaultNodeAttrs = {
|
||||
visible: true,
|
||||
listen: true,
|
||||
listening: true,
|
||||
name: undefined,
|
||||
alpha: 1,
|
||||
x: 0,
|
||||
@@ -475,21 +475,6 @@ Kinetic.Node.prototype = {
|
||||
rotation: this.getRotation() + (deg * Math.PI / 180)
|
||||
});
|
||||
},
|
||||
/**
|
||||
* listen or don't listen to events
|
||||
* @param {Boolean} listen
|
||||
*/
|
||||
listen: function(listen) {
|
||||
this.setAttrs({
|
||||
listen: listen
|
||||
});
|
||||
},
|
||||
/**
|
||||
* is listening or not
|
||||
*/
|
||||
isListening: function() {
|
||||
return this.attrs.listen;
|
||||
},
|
||||
/**
|
||||
* move node to top
|
||||
*/
|
||||
@@ -816,8 +801,8 @@ Kinetic.Node.prototype = {
|
||||
};
|
||||
|
||||
// add setters and getters
|
||||
Kinetic.GlobalObject.addSetters(Kinetic.Node, ['x', 'y', 'detectionType', 'rotation', 'alpha', 'name', 'id', 'draggable', 'dragConstraint', 'dragBounds']);
|
||||
Kinetic.GlobalObject.addGetters(Kinetic.Node, ['scale', 'x', 'y', 'detectionType', 'rotation', 'alpha', 'name', 'id', 'draggable', 'offset', 'dragConstraint', 'dragBounds']);
|
||||
Kinetic.GlobalObject.addSetters(Kinetic.Node, ['x', 'y', 'detectionType', 'rotation', 'alpha', 'name', 'id', 'draggable', 'dragConstraint', 'dragBounds', 'listening']);
|
||||
Kinetic.GlobalObject.addGetters(Kinetic.Node, ['scale', 'x', 'y', 'detectionType', 'rotation', 'alpha', 'name', 'id', 'draggable', 'offset', 'dragConstraint', 'dragBounds', 'listening']);
|
||||
|
||||
/**
|
||||
* set node x position
|
||||
@@ -881,6 +866,13 @@ Kinetic.GlobalObject.addGetters(Kinetic.Node, ['scale', 'x', 'y', 'detectionType
|
||||
* @config {Number} [bottom] bottom bounds position
|
||||
*/
|
||||
|
||||
/**
|
||||
* listen or don't listen to events
|
||||
* @name setListening
|
||||
* @methodOf Kinetic.Node.prototype
|
||||
* @param {Boolean} listening
|
||||
*/
|
||||
|
||||
/**
|
||||
* get scale
|
||||
* @name getScale
|
||||
@@ -953,4 +945,10 @@ Kinetic.GlobalObject.addGetters(Kinetic.Node, ['scale', 'x', 'y', 'detectionType
|
||||
* get drag bounds
|
||||
* @name getDragBounds
|
||||
* @methodOf Kinetic.Node.prototype
|
||||
*/
|
||||
|
||||
/**
|
||||
* determine if listening to events or not
|
||||
* @name getListening
|
||||
* @methodOf Kinetic.Node.prototype
|
||||
*/
|
@@ -531,7 +531,7 @@ else if(!isDragging && this.mouseMove) {
|
||||
// propapgate backwards through children
|
||||
for(var i = children.length - 1; i >= 0; i--) {
|
||||
var child = children[i];
|
||||
if(child.attrs.listen) {
|
||||
if(child.getListening()) {
|
||||
if(child.nodeType === 'Shape') {
|
||||
var exit = this._detectEvent(child, evt);
|
||||
if(exit) {
|
||||
@@ -575,7 +575,7 @@ else if(!isDragging && this.mouseMove) {
|
||||
var shapeDetected = false;
|
||||
for(var n = this.children.length - 1; n >= 0; n--) {
|
||||
var layer = this.children[n];
|
||||
if(layer.isVisible() && n >= 0 && layer.attrs.listen) {
|
||||
if(layer.isVisible() && n >= 0 && layer.getListening()) {
|
||||
if(this._traverseChildren(layer, evt)) {
|
||||
shapeDetected = true;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user