mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 02:37:59 +08:00
Add mouse wheel support
This commit is contained in:
20
src/Stage.js
20
src/Stage.js
@@ -19,6 +19,9 @@
|
||||
TAP = 'tap',
|
||||
DBL_TAP = 'dbltap',
|
||||
TOUCHMOVE = 'touchmove',
|
||||
DOMMOUSESCROLL = 'DOMMouseScroll',
|
||||
MOUSEWHEEL = 'mousewheel',
|
||||
WHEEL = 'wheel',
|
||||
|
||||
CONTENT_MOUSEOUT = 'contentMouseout',
|
||||
CONTENT_MOUSELEAVE = 'contentMouseleave',
|
||||
@@ -43,7 +46,7 @@
|
||||
UNDERSCORE = '_',
|
||||
CONTAINER = 'container',
|
||||
EMPTY_STRING = '',
|
||||
EVENTS = [MOUSEDOWN, MOUSEMOVE, MOUSEUP, MOUSEOUT, TOUCHSTART, TOUCHMOVE, TOUCHEND, MOUSEOVER],
|
||||
EVENTS = [MOUSEDOWN, MOUSEMOVE, MOUSEUP, MOUSEOUT, TOUCHSTART, TOUCHMOVE, TOUCHEND, MOUSEOVER, DOMMOUSESCROLL, MOUSEWHEEL, WHEEL],
|
||||
|
||||
// cached variables
|
||||
eventsLength = EVENTS.length;
|
||||
@@ -591,6 +594,21 @@
|
||||
dd._drag(evt);
|
||||
}
|
||||
},
|
||||
_DOMMouseScroll: function(evt) {
|
||||
this._mousewheel(evt);
|
||||
},
|
||||
_mousewheel: function(evt) {
|
||||
this._setPointerPosition(evt);
|
||||
var shape = this.getIntersection(this.getPointerPosition());
|
||||
|
||||
if (shape && shape.isListening()) {
|
||||
this.clickStartShape = shape;
|
||||
shape._fireAndBubble(MOUSEWHEEL, {evt: evt});
|
||||
}
|
||||
},
|
||||
_wheel: function(evt) {
|
||||
this._mousewheel(evt);
|
||||
},
|
||||
_setPointerPosition: function(evt) {
|
||||
var contentPosition = this._getContentPosition(),
|
||||
offsetX = evt.offsetX,
|
||||
|
Reference in New Issue
Block a user