mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-27 06:24:00 +00:00
Handle wheel event as a normal event with target. (#3612)
* wheel event with target * fix target detection
This commit is contained in:
parent
4df8ef3698
commit
920b83b513
3 changed files with 5 additions and 9 deletions
|
|
@ -1087,7 +1087,6 @@
|
|||
activeGroup = this.getActiveGroup(),
|
||||
activeObject = this.getActiveObject(),
|
||||
activeTarget;
|
||||
|
||||
// first check current group (if one exists)
|
||||
// active group does not check sub targets like normal groups.
|
||||
// if active group just exits.
|
||||
|
|
@ -1111,7 +1110,6 @@
|
|||
}
|
||||
|
||||
this.targets = [];
|
||||
|
||||
var target = this._searchPossibleTargets(this._objects, pointer);
|
||||
if (e[this.altSelectionKey] && target && activeTarget && target !== activeTarget) {
|
||||
target = activeTarget;
|
||||
|
|
|
|||
|
|
@ -351,10 +351,9 @@
|
|||
* @param {fabric.Object} targetObj receiving event
|
||||
*/
|
||||
_handleEvent: function(e, eventType, targetObj) {
|
||||
var target = typeof targetObj === undefined ? this.findTarget(e) : targetObj,
|
||||
var target = typeof targetObj === 'undefined' ? this.findTarget(e) : targetObj,
|
||||
targets = this.targets || [],
|
||||
options = { e: e, target: target, subTargets: targets };
|
||||
|
||||
this.fire('mouse:' + eventType, options);
|
||||
target && target.fire('mouse' + eventType, options);
|
||||
for (var i = 0; i < targets.length; i++) {
|
||||
|
|
@ -457,8 +456,7 @@
|
|||
*/
|
||||
__onMouseDown: function (e) {
|
||||
|
||||
var target = this.findTarget(e),
|
||||
pointer = this.getPointer(e, true);
|
||||
var target = this.findTarget(e);
|
||||
|
||||
// if right click just fire events
|
||||
var isRightClick = 'which' in e ? e.which === 3 : e.button === 2;
|
||||
|
|
@ -480,6 +478,7 @@
|
|||
}
|
||||
|
||||
// save pointer for check in __onMouseUp event
|
||||
var pointer = this.getPointer(e, true);
|
||||
this._previousPointer = pointer;
|
||||
|
||||
var shouldRender = this._shouldRender(target, pointer),
|
||||
|
|
@ -628,9 +627,7 @@
|
|||
* @param {Event} e Event object fired on mouseup
|
||||
*/
|
||||
__onMouseWheel: function(e) {
|
||||
this.fire('mouse:wheel', {
|
||||
e: e
|
||||
});
|
||||
this._handleEvent(e, 'wheel');
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
* @fires mouseup
|
||||
* @fires mouseover
|
||||
* @fires mouseout
|
||||
* @fires mousewheel
|
||||
*/
|
||||
fabric.Object = fabric.util.createClass(fabric.CommonMethods, /** @lends fabric.Object.prototype */ {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue