From 79d048ac8167b87507561c93f58c0921fd8307ab Mon Sep 17 00:00:00 2001 From: thatcher Date: Wed, 5 Sep 2012 11:35:42 -0400 Subject: [PATCH] add lazy load to drag too, not just scroll --- build.properties | 2 +- openseadragon.js | 19 ++++++------------- src/referencestrip.js | 17 +++++------------ 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/build.properties b/build.properties index 5187d2a9..33a72f19 100644 --- a/build.properties +++ b/build.properties @@ -6,7 +6,7 @@ PROJECT: openseadragon BUILD_MAJOR: 0 BUILD_MINOR: 9 -BUILD_ID: 70 +BUILD_ID: 72 BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} diff --git a/openseadragon.js b/openseadragon.js index 0913f16b..c3081437 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -1,5 +1,5 @@ /** - * @version OpenSeadragon 0.9.70 + * @version OpenSeadragon 0.9.72 * * @fileOverview *

@@ -6978,41 +6978,38 @@ function onStripDrag( tracker, position, delta, shift ) { offsetTop = Number(this.element.style.marginTop.replace('px','')), scrollWidth = Number(this.element.style.width.replace('px','')), scrollHeight = Number(this.element.style.height.replace('px','')), - viewerSize; + viewerSize = $.getElementSize( this.viewer.canvas ); this.dragging = true; if ( this.element ) { if( 'horizontal' == this.scroll ){ if ( -delta.x > 0 ) { //forward - viewerSize = $.getElementSize( this.viewer.canvas ); if( offsetLeft > -(scrollWidth - viewerSize.x)){ this.element.style.marginLeft = ( offsetLeft + (delta.x * 2) ) + 'px'; + loadPanels( this, viewerSize.x, offsetLeft + (delta.x * 2) ); } } else if ( -delta.x < 0 ) { //reverse if( offsetLeft < 0 ){ this.element.style.marginLeft = ( offsetLeft + (delta.x * 2) ) + 'px'; } - } else { - return false; } }else{ if ( -delta.y > 0 ) { //forward - viewerSize = $.getElementSize( this.viewer.canvas ); if( offsetTop > -(scrollHeight - viewerSize.y)){ this.element.style.marginTop = ( offsetTop + (delta.y * 2) ) + 'px'; + loadPanels( this, viewerSize.y, offsetTop + (delta.y * 2) ); } } else if ( -delta.y < 0 ) { //reverse if( offsetTop < 0 ){ this.element.style.marginTop = ( offsetTop + (delta.y * 2) ) + 'px'; } - } else { - return false; } } } + return false; }; @@ -7042,8 +7039,6 @@ function onStripScroll( tracker, position, scroll, shift ) { if( offsetLeft < 0 ){ this.element.style.marginLeft = ( offsetLeft - (scroll * 60) ) + 'px'; } - } else { - return false; } }else{ if ( scroll < 0 ) { @@ -7057,8 +7052,6 @@ function onStripScroll( tracker, position, scroll, shift ) { if( offsetTop < 0 ){ this.element.style.marginTop = ( offsetTop + (scroll * 60) ) + 'px'; } - } else { - return false; } } } @@ -7079,7 +7072,7 @@ function loadPanels(strip, viewerSize, scroll){ } activePanels = Math.ceil( (Math.abs(scroll) + viewerSize ) / panelSize ) + 1; - for( i = 0; i < activePanels; i++ ){ + for( i = 0; i < activePanels && i < strip.panels.length; i++ ){ element = strip.panels[ i ]; if ( !element.activePanel ){ miniViewer = new $.Viewer( { diff --git a/src/referencestrip.js b/src/referencestrip.js index c403fca6..ed377207 100644 --- a/src/referencestrip.js +++ b/src/referencestrip.js @@ -234,41 +234,38 @@ function onStripDrag( tracker, position, delta, shift ) { offsetTop = Number(this.element.style.marginTop.replace('px','')), scrollWidth = Number(this.element.style.width.replace('px','')), scrollHeight = Number(this.element.style.height.replace('px','')), - viewerSize; + viewerSize = $.getElementSize( this.viewer.canvas ); this.dragging = true; if ( this.element ) { if( 'horizontal' == this.scroll ){ if ( -delta.x > 0 ) { //forward - viewerSize = $.getElementSize( this.viewer.canvas ); if( offsetLeft > -(scrollWidth - viewerSize.x)){ this.element.style.marginLeft = ( offsetLeft + (delta.x * 2) ) + 'px'; + loadPanels( this, viewerSize.x, offsetLeft + (delta.x * 2) ); } } else if ( -delta.x < 0 ) { //reverse if( offsetLeft < 0 ){ this.element.style.marginLeft = ( offsetLeft + (delta.x * 2) ) + 'px'; } - } else { - return false; } }else{ if ( -delta.y > 0 ) { //forward - viewerSize = $.getElementSize( this.viewer.canvas ); if( offsetTop > -(scrollHeight - viewerSize.y)){ this.element.style.marginTop = ( offsetTop + (delta.y * 2) ) + 'px'; + loadPanels( this, viewerSize.y, offsetTop + (delta.y * 2) ); } } else if ( -delta.y < 0 ) { //reverse if( offsetTop < 0 ){ this.element.style.marginTop = ( offsetTop + (delta.y * 2) ) + 'px'; } - } else { - return false; } } } + return false; }; @@ -298,8 +295,6 @@ function onStripScroll( tracker, position, scroll, shift ) { if( offsetLeft < 0 ){ this.element.style.marginLeft = ( offsetLeft - (scroll * 60) ) + 'px'; } - } else { - return false; } }else{ if ( scroll < 0 ) { @@ -313,8 +308,6 @@ function onStripScroll( tracker, position, scroll, shift ) { if( offsetTop < 0 ){ this.element.style.marginTop = ( offsetTop + (scroll * 60) ) + 'px'; } - } else { - return false; } } } @@ -335,7 +328,7 @@ function loadPanels(strip, viewerSize, scroll){ } activePanels = Math.ceil( (Math.abs(scroll) + viewerSize ) / panelSize ) + 1; - for( i = 0; i < activePanels; i++ ){ + for( i = 0; i < activePanels && i < strip.panels.length; i++ ){ element = strip.panels[ i ]; if ( !element.activePanel ){ miniViewer = new $.Viewer( {