Added a patch to help slow down the scroll devices that fire too fast. This new code reduces the number of 'canvas-scroll' events that fire and slows down the zoom process.

This commit is contained in:
Grant Echols 2015-10-27 14:00:45 -06:00
parent fb8e19b50d
commit 19c6179533
2 changed files with 50 additions and 32 deletions

View File

@ -255,6 +255,11 @@
* @property {Boolean} [preserveImageSizeOnResize=false]
* Set to true to have the image size preserved when the viewer is resized. This requires autoResize=true (default).
*
* @property {Number} [minScrollDelta=3]
* Number of milliseconds between canvas-scroll events. This value helps normalize the rate of canvas-scroll
* events between different devices, causing the faster devices to slow down enough to make the zoom control
* more manageable.
*
* @property {Number} [pixelsPerWheelLine=40]
* For pixel-resolution scrolling devices, the number of pixels equal to one scroll line.
*
@ -1003,6 +1008,7 @@ if (typeof define === 'function' && define.amd) {
pixelsPerWheelLine: 40,
autoResize: true,
preserveImageSizeOnResize: false, // requires autoResize=true
minScrollDelta: 3,
//DEFAULT CONTROL SETTINGS
showSequenceControl: true, //SEQUENCE

View File

@ -2735,9 +2735,20 @@ function onCanvasPinch( event ) {
return false;
}
var lastScroll = new Date().getTime();
function onCanvasScroll( event ) {
var gestureSettings,
factor;
factor,
thisScroll,
deltaScroll;
/* Certain scroll devices fire the scroll event way too fast so we are injecting a simple adjustment to keep things
* partially normalized. If we have already fired an event within the last 'minScrollDelta' milliseconds we skip
* this one and wait for the next event. */
thisScroll = new Date().getTime();
deltaScroll = thisScroll - lastScroll;
if (deltaScroll > this.minScrollDelta) {
lastScroll = thisScroll;
if ( !event.preventDefaultAction && this.viewport ) {
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
@ -2771,6 +2782,7 @@ function onCanvasScroll( event ) {
shift: event.shift,
originalEvent: event.originalEvent
});
}
if (gestureSettings && gestureSettings.scrollToZoom) {
//cancels event