mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-29 00:26:10 +03:00
Add counter to avoid trying to set scroll indefinitly
Style and spelling fixes Set scrolls tests setup inside own function
This commit is contained in:
parent
fafc985ada
commit
6aca0c0886
@ -783,10 +783,13 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
|
||||
// After exiting fullPage or fullScreen, it can take some time
|
||||
// before the browser can actually set the scroll.
|
||||
var restoreScrollCounter = 0;
|
||||
var restoreScroll = function() {
|
||||
$.setPageScroll( _this.pageScroll );
|
||||
var pageScroll = $.getPageScroll();
|
||||
if ( pageScroll.x !== _this.pageScroll.x ||
|
||||
restoreScrollCounter++;
|
||||
if ( restoreScrollCounter < 10 &&
|
||||
pageScroll.x !== _this.pageScroll.x ||
|
||||
pageScroll.y !== _this.pageScroll.y ) {
|
||||
$.requestAnimationFrame( restoreScroll );
|
||||
}
|
||||
@ -975,7 +978,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
beginZoomingOutHandler = $.delegate( this, beginZoomingOut ),
|
||||
doSingleZoomOutHandler = $.delegate( this, doSingleZoomOut ),
|
||||
onHomeHandler = $.delegate( this, onHome ),
|
||||
onFullPageHandler = $.delegate( this, onFullScreen ),
|
||||
onFullScreenHandler = $.delegate( this, onFullScreen ),
|
||||
onFocusHandler = $.delegate( this, onFocus ),
|
||||
onBlurHandler = $.delegate( this, onBlur ),
|
||||
navImages = this.navImages,
|
||||
@ -1050,7 +1053,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
srcGroup: resolveUrl( this.prefixUrl, navImages.fullpage.GROUP ),
|
||||
srcHover: resolveUrl( this.prefixUrl, navImages.fullpage.HOVER ),
|
||||
srcDown: resolveUrl( this.prefixUrl, navImages.fullpage.DOWN ),
|
||||
onRelease: onFullPageHandler,
|
||||
onRelease: onFullScreenHandler,
|
||||
onFocus: onFocusHandler,
|
||||
onBlur: onBlurHandler
|
||||
}));
|
||||
@ -1665,7 +1668,7 @@ function updateOnce( viewer ) {
|
||||
//viewer.profiler.endUpdate();
|
||||
}
|
||||
|
||||
// This function resize the viewport and recenter the image
|
||||
// This function resizes the viewport and recenters the image
|
||||
// as it was before resizing.
|
||||
// TODO: better adjust width and height. The new width and height
|
||||
// should depend on the image dimensions and on the dimensions
|
||||
|
@ -2,30 +2,22 @@
|
||||
|
||||
( function() {
|
||||
|
||||
var origWidth, origHeight;
|
||||
|
||||
module( 'Polyfills', {
|
||||
setup: function() {
|
||||
|
||||
origWidth = $( "body" ).width();
|
||||
origHeight = $( "body" ).height();
|
||||
$( "body" ).width( origWidth + 10000 );
|
||||
$( "body" ).height( origHeight + 10000 );
|
||||
|
||||
$( document ).scrollLeft( 0 );
|
||||
$( document ).scrollTop( 0 );
|
||||
testLog.reset();
|
||||
},
|
||||
teardown: function() {
|
||||
$( "body" ).width( origWidth );
|
||||
$( "body" ).height( origHeight );
|
||||
$( document ).scrollLeft( 0 );
|
||||
$( document ).scrollTop( 0 );
|
||||
}
|
||||
} );
|
||||
|
||||
// ----------
|
||||
test( 'pageScroll', function() {
|
||||
// Setup
|
||||
var origWidth = $( "body" ).width(),
|
||||
origHeight = $( "body" ).height();
|
||||
$( "body" ).width( origWidth + 10000 );
|
||||
$( "body" ).height( origHeight + 10000 );
|
||||
$( document ).scrollLeft( 0 );
|
||||
$( document ).scrollTop( 0 );
|
||||
// End setup
|
||||
|
||||
// Test get
|
||||
var originalGetPageScroll = OpenSeadragon.getPageScroll;
|
||||
@ -125,6 +117,12 @@
|
||||
equal( currentSetPageScroll, OpenSeadragon.setPageScroll,
|
||||
"OpenSeadragon.setPageScroll must not be reassigned after first call." );
|
||||
|
||||
|
||||
// Teardown
|
||||
$( "body" ).width( origWidth );
|
||||
$( "body" ).height( origHeight );
|
||||
$( document ).scrollLeft( 0 );
|
||||
$( document ).scrollTop( 0 );
|
||||
} );
|
||||
|
||||
} )();
|
||||
|
Loading…
Reference in New Issue
Block a user