changed listen property to listening, listen() to setListening(), and isListening() to getListening() for consistency

This commit is contained in:
Eric Rowell 2012-06-18 23:12:56 -07:00
parent c8d8aa6028
commit 76c85a639e
5 changed files with 46 additions and 50 deletions

38
dist/kinetic-core.js vendored
View File

@ -395,7 +395,7 @@ window.requestAnimFrame = (function(callback) {
Kinetic.Node = function(config) {
this.defaultNodeAttrs = {
visible: true,
listen: true,
listening: true,
name: undefined,
alpha: 1,
x: 0,
@ -859,21 +859,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
*/
@ -1200,8 +1185,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
@ -1265,6 +1250,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
@ -1338,6 +1330,12 @@ Kinetic.GlobalObject.addGetters(Kinetic.Node, ['scale', 'x', 'y', 'detectionType
* @name getDragBounds
* @methodOf Kinetic.Node.prototype
*/
/**
* determine if listening to events or not
* @name getListening
* @methodOf Kinetic.Node.prototype
*/
///////////////////////////////////////////////////////////////////////
// Container
///////////////////////////////////////////////////////////////////////
@ -2099,7 +2097,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) {
@ -2143,7 +2141,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;

File diff suppressed because one or more lines are too long

View File

@ -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
*/

View File

@ -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;

View File

@ -2948,19 +2948,19 @@ Test.prototype.tests = {
width: 200,
height: 50,
fill: 'red',
listen: false
listening: false
});
layer.add(rect).add(rect2);
stage.add(layer);
test(rect.isListening() === true, 'rect should be listening');
rect.listen(false);
test(rect.isListening() === false, 'rect should not be listening');
test(rect.getListening() === true, 'rect should be listening');
rect.setListening(false);
test(rect.getListening() === false, 'rect should not be listening');
test(rect2.isListening() === false, 'rect2 should not be listening');
rect2.listen(true);
test(rect2.isListening() === true, 'rect2 should be listening');
test(rect2.getListening() === false, 'rect2 should not be listening');
rect2.setListening(true);
test(rect2.getListening() === true, 'rect2 should be listening');
},
'NODE - test offset attr change': function(containerId) {
/*
@ -4533,7 +4533,7 @@ Test.prototype.tests = {
});
circle.setDraggable(true);
test(circle.getDraggable(), 'draggable should be true');
test(circle.getDraggable(), 'draggable should be true');
circle.setDraggable(true);
test(circle.getDraggable(), 'draggable should be true');
circle.setDraggable(false);