added mouseenter and mouseleave events. mouseover and mouseout were actually functioning like mouseenter and mouseleave. mouseover and mouseout now work similar to traditional DOM mouseover and mouseout. This change enables event delegation to work correctly

This commit is contained in:
ericdrowell
2012-10-03 10:53:09 -07:00
parent c6237b59e6
commit b6eb2cdf82
6 changed files with 68 additions and 58 deletions

View File

@@ -460,6 +460,7 @@ Kinetic.Stage.prototype = {
var targetShape = this.targetShape;
if(targetShape && !go.drag.moving) {
targetShape._handleEvent('mouseout', evt);
argetShape._handleEvent('mouseleave', evt);
this.targetShape = null;
}
this.mousePos = undefined;
@@ -478,8 +479,10 @@ Kinetic.Stage.prototype = {
if(!go.drag.moving && obj.pixel[3] === 255 && (!this.targetShape || this.targetShape._id !== shape._id)) {
if(this.targetShape) {
this.targetShape._handleEvent('mouseout', evt, shape);
this.targetShape._handleEvent('mouseleave', evt, shape);
}
shape._handleEvent('mouseover', evt, this.targetShape);
shape._handleEvent('mouseenter', evt, this.targetShape);
this.targetShape = shape;
}
else {
@@ -493,6 +496,7 @@ Kinetic.Stage.prototype = {
*/
else if(this.targetShape && !go.drag.moving) {
this.targetShape._handleEvent('mouseout', evt);
this.targetShape._handleEvent('mouseleave', evt);
this.targetShape = null;
}