Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the mouse over/ mouse out event fire in the mouseMove events only #4283

Merged
merged 1 commit into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions src/canvas.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,18 +1113,15 @@
this.targets = [];

if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) {
this._fireOverOutEvents(activeObject, e);
return activeObject;
}
// if we hit the corner of an activeObject, let's return that.
if (aObjects.length === 1 && activeObject._findTargetCorner(pointer)) {
this._fireOverOutEvents(activeObject, e);
return activeObject;
}
if (aObjects.length === 1 &&
activeObject === this._searchPossibleTargets([activeObject], pointer)) {
if (!this.preserveObjectStacking) {
this._fireOverOutEvents(activeObject, e);
return activeObject;
}
else {
Expand All @@ -1135,36 +1132,9 @@
if (e[this.altSelectionKey] && target && activeTarget && target !== activeTarget) {
target = activeTarget;
}
this._fireOverOutEvents(target, e);
return target;
},

/**
* @private
*/
_fireOverOutEvents: function(target, e) {
var overOpt, outOpt, hoveredTarget = this._hoveredTarget;
if (hoveredTarget !== target) {
overOpt = { e: e, target: target, previousTarget: this._hoveredTarget };
outOpt = { e: e, target: this._hoveredTarget, nextTarget: target };
this._hoveredTarget = target;
}
if (target) {
if (hoveredTarget !== target) {
if (hoveredTarget) {
this.fire('mouse:out', outOpt);
hoveredTarget.fire('mouseout', outOpt);
}
this.fire('mouse:over', overOpt);
target.fire('mouseover', overOpt);
}
}
else if (hoveredTarget) {
this.fire('mouse:out', outOpt);
hoveredTarget.fire('mouseout', outOpt);
}
},

/**
* @private
*/
Expand Down
4 changes: 2 additions & 2 deletions src/gradient.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@
return a.offset - b.offset;
});
if (object.type === 'path') {
offsetX = 0;
offsetY = 0;
offsetX -= object.pathOffset.x;
offsetY -= object.pathOffset.y;
}
for (var prop in coords) {
if (prop === 'x1' || prop === 'x2') {
Expand Down
27 changes: 27 additions & 0 deletions src/mixins/canvas_events.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,13 +653,40 @@
else if (!this._currentTransform) {
target = this.findTarget(e);
this._setCursorFromEvent(e, target);
this._fireOverOutEvents(target, e);
}
else {
this._transformObject(e);
}
this._handleEvent(e, 'move', target ? target : null);
},

/**
* @private
*/
_fireOverOutEvents: function(target, e) {
var overOpt, outOpt, hoveredTarget = this._hoveredTarget;
if (hoveredTarget !== target) {
overOpt = { e: e, target: target, previousTarget: this._hoveredTarget };
outOpt = { e: e, target: this._hoveredTarget, nextTarget: target };
this._hoveredTarget = target;
}
if (target) {
if (hoveredTarget !== target) {
if (hoveredTarget) {
this.fire('mouse:out', outOpt);
hoveredTarget.fire('mouseout', outOpt);
}
this.fire('mouse:over', overOpt);
target.fire('mouseover', overOpt);
}
}
else if (hoveredTarget) {
this.fire('mouse:out', outOpt);
hoveredTarget.fire('mouseout', outOpt);
}
},

/**
* Method that defines actions when an Event Mouse Wheel
* @param {Event} e Event object fired on mouseup
Expand Down