Fix mousewheel event for IE11

This commit is contained in:
jdescottes 2015-01-24 00:00:08 +01:00
parent 5224c9ddd8
commit c7131678f8

View File

@ -79,7 +79,7 @@
var body = $('body');
this.container.mousedown($.proxy(this.onMousedown_, this));
if (pskl.utils.UserAgent.isChrome) {
if (pskl.utils.UserAgent.isChrome || pskl.utils.UserAgent.isIE11) {
this.container.on('mousewheel', $.proxy(this.onMousewheel_, this));
} else {
this.container.on('wheel', $.proxy(this.onMousewheel_, this));
@ -222,7 +222,14 @@
ns.DrawingController.prototype.onMousewheel_ = function (jQueryEvent) {
var event = jQueryEvent.originalEvent;
// Ratio between wheelDeltaY (mousewheel event) and deltaY (wheel event) is -40
var delta = event.wheelDeltaY || (-40 * event.deltaY);
var delta;
if (pskl.utils.UserAgent.isChrome) {
delta = event.wheelDeltaY;
} else if (pskl.utils.UserAgent.isIE11) {
delta = event.wheelDelta;
} else if (pskl.utils.UserAgent.isFirefox) {
delta = -40 * event.deltaY;
}
var modifier = Math.abs(delta/120);
if (delta > 0) {
this.increaseZoom_(modifier);
@ -231,6 +238,16 @@
}
};
ns.DrawingController.prototype.increaseZoom_ = function (zoomMultiplier) {
var step = (zoomMultiplier || 1) * this.getZoomStep_();
this.setZoom_(this.renderer.getZoom() + step);
};
ns.DrawingController.prototype.decreaseZoom_ = function (zoomMultiplier) {
var step = (zoomMultiplier || 1) * this.getZoomStep_();
this.setZoom_(this.renderer.getZoom() - step);
};
/**
* @private
*/
@ -397,16 +414,6 @@
this.setZoom_(this.calculateZoom_());
};
ns.DrawingController.prototype.increaseZoom_ = function (zoomMultiplier) {
var step = (zoomMultiplier || 1) * this.getZoomStep_();
this.setZoom_(this.renderer.getZoom() + step);
};
ns.DrawingController.prototype.decreaseZoom_ = function (zoomMultiplier) {
var step = (zoomMultiplier || 1) * this.getZoomStep_();
this.setZoom_(this.renderer.getZoom() - step);
};
ns.DrawingController.prototype.getZoomStep_ = function () {
return this.calculateZoom_() / 10;
};