mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Fix: cannot detect mac touchpad : switch to throttling
This commit is contained in:
parent
6dc3a2bdf7
commit
0fec4eff4a
@ -1,8 +1,7 @@
|
||||
(function () {
|
||||
|
||||
var ns = $.namespace("pskl.controller");
|
||||
|
||||
var MAC_TOUCHPAD_SKIP = 8;
|
||||
var MOUSEWHEEL_THROTTLING = 20;
|
||||
|
||||
ns.DrawingController = function (piskelController, paletteController, container) {
|
||||
/**
|
||||
@ -47,7 +46,7 @@
|
||||
this.previousMousemoveTime = 0;
|
||||
this.currentToolBehavior = null;
|
||||
|
||||
this.skipMouseWheelCounter_ = 0;
|
||||
this.lastMouseWheel_ = 0;
|
||||
|
||||
// State of clicked button (need to be stateful here, see comment in getCurrentColor_)
|
||||
this.currentMouseButton_ = Constants.LEFT_BUTTON;
|
||||
@ -227,21 +226,18 @@
|
||||
};
|
||||
|
||||
ns.DrawingController.prototype.onMousewheel_ = function (jQueryEvent) {
|
||||
var now = Date.now();
|
||||
|
||||
if (now - this.lastMouseWheel_ > MOUSEWHEEL_THROTTLING) {
|
||||
this.lastMouseWheel_ = now;
|
||||
var event = jQueryEvent.originalEvent;
|
||||
var delta = event.wheelDeltaY || (-2 * event.deltaY);
|
||||
|
||||
var isMacTouchpad = typeof event.webkitDirectionInvertedFromDevice === 'boolean';
|
||||
if (isMacTouchpad) {
|
||||
if ((++this.skipMouseWheelCounter_%MAC_TOUCHPAD_SKIP)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (delta > 0) {
|
||||
this.increaseZoom_();
|
||||
} else if (delta < 0) {
|
||||
this.decreaseZoom_();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user