Updates as per code review requests

This commit is contained in:
Grant Echols 2015-10-28 17:07:51 -06:00
parent ad4bbb9daf
commit 40edbd7a1c
2 changed files with 10 additions and 9 deletions

View File

@ -255,7 +255,7 @@
* @property {Boolean} [preserveImageSizeOnResize=false] * @property {Boolean} [preserveImageSizeOnResize=false]
* Set to true to have the image size preserved when the viewer is resized. This requires autoResize=true (default). * Set to true to have the image size preserved when the viewer is resized. This requires autoResize=true (default).
* *
* @property {Number} [minScrollDeltaMS=3] * @property {Number} [minScrollDeltaTime=50]
* Number of milliseconds between canvas-scroll events. This value helps normalize the rate of canvas-scroll * 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 * events between different devices, causing the faster devices to slow down enough to make the zoom control
* more manageable. * more manageable.
@ -1008,7 +1008,7 @@ if (typeof define === 'function' && define.amd) {
pixelsPerWheelLine: 40, pixelsPerWheelLine: 40,
autoResize: true, autoResize: true,
preserveImageSizeOnResize: false, // requires autoResize=true preserveImageSizeOnResize: false, // requires autoResize=true
minScrollDeltaMS: 3, minScrollDeltaTime: 50,
//DEFAULT CONTROL SETTINGS //DEFAULT CONTROL SETTINGS
showSequenceControl: true, //SEQUENCE showSequenceControl: true, //SEQUENCE

View File

@ -203,6 +203,8 @@ $.Viewer = function( options ) {
this._loadQueue = []; this._loadQueue = [];
this.currentOverlays = []; this.currentOverlays = [];
this._lastScrollTime = $.now(); // variable used to help normalize the scroll event speed of different devices
//Inherit some behaviors and properties //Inherit some behaviors and properties
$.EventSource.call( this ); $.EventSource.call( this );
@ -2735,20 +2737,19 @@ function onCanvasPinch( event ) {
return false; return false;
} }
var lastScroll = new Date().getTime();
function onCanvasScroll( event ) { function onCanvasScroll( event ) {
var gestureSettings, var gestureSettings,
factor, factor,
thisScroll, thisScrollTime,
deltaScroll; deltaScrollTime;
/* Certain scroll devices fire the scroll event way too fast so we are injecting a simple adjustment to keep things /* 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 * partially normalized. If we have already fired an event within the last 'minScrollDelta' milliseconds we skip
* this one and wait for the next event. */ * this one and wait for the next event. */
thisScroll = new Date().getTime(); thisScrollTime = $.now();
deltaScroll = thisScroll - lastScroll; deltaScrollTime = thisScrollTime - this._lastScrollTime;
if (deltaScroll > this.minScrollDeltaMS) { if (deltaScrollTime > this.minScrollDeltaTime) {
lastScroll = thisScroll; this._lastScrollTime = thisScrollTime;
if ( !event.preventDefaultAction && this.viewport ) { if ( !event.preventDefaultAction && this.viewport ) {
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );