mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-16 22:10:32 +00:00
Added new custom version of event.js. Added event listeners for shake, drag and orientation change.
Custom version available: https://github.com/rykerwilliams/Event.js
This commit is contained in:
parent
888f324e46
commit
88aa0df407
4 changed files with 43 additions and 1775 deletions
1776
lib/event.js
1776
lib/event.js
File diff suppressed because one or more lines are too long
|
|
@ -42,10 +42,22 @@
|
|||
_this.__onTransformGesture(e, s);
|
||||
};
|
||||
|
||||
this._onDrag = function(e, s) {
|
||||
_this.__onDrag(e, s);
|
||||
};
|
||||
|
||||
this._onMouseWheel = function(e, s) {
|
||||
_this.__onMouseWheel(e, s);
|
||||
};
|
||||
|
||||
this._onOrientationChange = function(e,s) {
|
||||
_this.__onOrientationChange(e,s);
|
||||
};
|
||||
|
||||
this._onShake = function(e,s) {
|
||||
_this.__onShake(e,s);
|
||||
};
|
||||
|
||||
addListener(fabric.window, 'resize', this._onResize);
|
||||
|
||||
if (fabric.isTouchSupported) {
|
||||
|
|
@ -54,6 +66,9 @@
|
|||
|
||||
if (typeof Event !== 'undefined' && 'add' in Event) {
|
||||
Event.add(this.upperCanvasEl, 'gesture', this._onGesture);
|
||||
Event.add(this.upperCanvasEl, 'drag', this._onDrag);
|
||||
Event.add(this.upperCanvasEl, 'orientation', this._onOrientationChange);
|
||||
Event.add(this.upperCanvasEl, 'shake', this._onShake);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,26 @@
|
|||
this.fire('touch:gesture', {target: target, e: e, self: self});
|
||||
},
|
||||
|
||||
/**
|
||||
* Method that defines actions when an Event.js drag is detected.
|
||||
*
|
||||
* @param e Event object by Event.js
|
||||
* @param self Event proxy object by Event.js
|
||||
*/
|
||||
__onDrag: function(e, self) {
|
||||
this.fire('touch:drag', {e: e, self: self});
|
||||
},
|
||||
|
||||
/**
|
||||
* Method that defines actions when an Event.js orientation event is detected.
|
||||
*
|
||||
* @param e Event object by Event.js
|
||||
* @param self Event proxy object by Event.js
|
||||
*/
|
||||
__onOrientationChange: function(e, self) {
|
||||
this.fire('touch:orientation', {e: e, self: self});
|
||||
},
|
||||
|
||||
/**
|
||||
* Scales an object by a factor
|
||||
* @param s {Number} The scale factor to apply to the current scale level
|
||||
|
|
|
|||
|
|
@ -978,17 +978,22 @@
|
|||
|
||||
if (!this.interactive) return this;
|
||||
|
||||
removeListener(fabric.window, 'resize', this._onResize);
|
||||
|
||||
if (fabric.isTouchSupported) {
|
||||
removeListener(this.upperCanvasEl, 'touchstart', this._onMouseDown);
|
||||
removeListener(this.upperCanvasEl, 'touchmove', this._onMouseMove);
|
||||
if (typeof Event !== 'undefined' && 'remove' in Event) {
|
||||
Event.remove(this.upperCanvasEl, 'gesture', this._onGesture);
|
||||
Event.remove(this.upperCanvasEl, 'drag', this._onDrag);
|
||||
Event.remove(this.upperCanvasEl, 'orientation', this._onOrientationChange);
|
||||
Event.remove(this.upperCanvasEl, 'shake', this._onShake);
|
||||
}
|
||||
}
|
||||
else {
|
||||
removeListener(this.upperCanvasEl, 'mousedown', this._onMouseDown);
|
||||
removeListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
|
||||
removeListener(fabric.window, 'resize', this._onResize);
|
||||
removeListener(this.upperCanvasEl, 'mousewheel', this._onMouseWheel);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue