diff --git a/script.js b/script.js index 715d5ea..8c3da34 100644 --- a/script.js +++ b/script.js @@ -1,59 +1,65 @@ /** * CC BY SA 3.0 * https://stackoverflow.com/a/819455/3451846 */ function resizeIFrameToFitContent( iFrame ) { if( iFrame ) { var $iframe = $(iFrame); $iframe.height( $iframe.contents().height() ); $iframe.width( $iframe.contents().width() ); // show if( ! this.executedFirstTime ) { $( '#full-block' ).hide( 'slow' ); this.executedFirstTime = true; /* scroll half of this page */ setInterval( scrollHalf, SEQUENCE.interval ); } } } function expandIframes() { // or, to resize all iframes: var iframes = document.querySelectorAll('iframe'); for( var i = 0; i < iframes.length; i++ ) { resizeIFrameToFitContent( iframes[i] ); } } function loadNextPage() { window.location = SEQUENCE.nextURL; } function scrollHalf() { var fullHeight = $(document).height(); var h = $(window).height(); var halfWindow = h / 1.8; var currentPosition = $(document).scrollTop(); var nextPosition = currentPosition + halfWindow; + var fixGiova = 5; // px - if( currentPosition + h >= fullHeight ) { + console.log( "document height" , fullHeight ); // 1558 + console.log( "current", currentPosition ); // 510 + console.log( "window height", h ); // 1047 + + // GDS has 510 + 1047 = 1557 instead of 1558 + if( currentPosition + h + fixGiova >= fullHeight ) { loadNextPage(); } $( '#full-block' ).show( 'slow', function() { window.scrollTo( 0, nextPosition ); $( '#full-block' ).hide( 'slow' ); } ); } $( function() { /* adapt the page to the real dimensions */ setInterval( expandIframes, 400 ); } );