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]
* 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
* events between different devices, causing the faster devices to slow down enough to make the zoom control
* more manageable.
@ -1008,7 +1008,7 @@ if (typeof define === 'function' && define.amd) {
pixelsPerWheelLine: 40,
autoResize: true,
preserveImageSizeOnResize: false, // requires autoResize=true
minScrollDeltaMS: 3,
minScrollDeltaTime: 50,
//DEFAULT CONTROL SETTINGS
showSequenceControl: true, //SEQUENCE

View File

@ -203,6 +203,8 @@ $.Viewer = function( options ) {
this._loadQueue = [];
this.currentOverlays = [];
this._lastScrollTime = $.now(); // variable used to help normalize the scroll event speed of different devices
//Inherit some behaviors and properties
$.EventSource.call( this );
@ -2735,20 +2737,19 @@ function onCanvasPinch( event ) {
return false;
}
var lastScroll = new Date().getTime();
function onCanvasScroll( event ) {
var gestureSettings,
factor,
thisScroll,
deltaScroll;
thisScrollTime,
deltaScrollTime;
/* 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.minScrollDeltaMS) {
lastScroll = thisScroll;
thisScrollTime = $.now();
deltaScrollTime = thisScrollTime - this._lastScrollTime;
if (deltaScrollTime > this.minScrollDeltaTime) {
this._lastScrollTime = thisScrollTime;
if ( !event.preventDefaultAction && this.viewport ) {
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );