Fix : zoom step depends on mousewheel event delta value
This commit is contained in:
parent
0fec4eff4a
commit
f1b6ea4ae3
1 changed files with 13 additions and 18 deletions
|
@ -1,7 +1,6 @@
|
|||
(function () {
|
||||
|
||||
var ns = $.namespace("pskl.controller");
|
||||
var MOUSEWHEEL_THROTTLING = 20;
|
||||
|
||||
ns.DrawingController = function (piskelController, paletteController, container) {
|
||||
/**
|
||||
|
@ -46,8 +45,6 @@
|
|||
this.previousMousemoveTime = 0;
|
||||
this.currentToolBehavior = null;
|
||||
|
||||
this.lastMouseWheel_ = 0;
|
||||
|
||||
// State of clicked button (need to be stateful here, see comment in getCurrentColor_)
|
||||
this.currentMouseButton_ = Constants.LEFT_BUTTON;
|
||||
};
|
||||
|
@ -172,12 +169,14 @@
|
|||
this.setZoom_(this.calculateZoom_());
|
||||
};
|
||||
|
||||
ns.DrawingController.prototype.increaseZoom_ = function () {
|
||||
this.setZoom_(this.renderer.getZoom() + this.getZoomStep_());
|
||||
ns.DrawingController.prototype.increaseZoom_ = function (zoomMultiplier) {
|
||||
var step = (zoomMultiplier || 1) * this.getZoomStep_();
|
||||
this.setZoom_(this.renderer.getZoom() + step);
|
||||
};
|
||||
|
||||
ns.DrawingController.prototype.decreaseZoom_ = function () {
|
||||
this.setZoom_(this.renderer.getZoom() - this.getZoomStep_());
|
||||
ns.DrawingController.prototype.decreaseZoom_ = function (zoomMultiplier) {
|
||||
var step = (zoomMultiplier || 1) * this.getZoomStep_();
|
||||
this.setZoom_(this.renderer.getZoom() - step);
|
||||
};
|
||||
|
||||
ns.DrawingController.prototype.getZoomStep_ = function () {
|
||||
|
@ -226,17 +225,13 @@
|
|||
};
|
||||
|
||||
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);
|
||||
if (delta > 0) {
|
||||
this.increaseZoom_();
|
||||
} else if (delta < 0) {
|
||||
this.decreaseZoom_();
|
||||
}
|
||||
var event = jQueryEvent.originalEvent;
|
||||
var delta = event.wheelDeltaY || (-2 * event.deltaY);
|
||||
var modifier = Math.abs(delta/120);
|
||||
if (delta > 0) {
|
||||
this.increaseZoom_(modifier);
|
||||
} else if (delta < 0) {
|
||||
this.decreaseZoom_(modifier);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue