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