From: gladoscc Date: Fri, 2 Jan 2015 16:02:48 +0000 (+1100) Subject: jQuery.footHovzer: Fix scrolling issues X-Git-Tag: 1.31.0-rc.0~12818^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=051edd4d7f2663b0ee1afc1954b2e5bf3b5f1505;p=lhc%2Fweb%2Fwiklou.git jQuery.footHovzer: Fix scrolling issues Fix scrollbar appearing if the page does not fill the screen, and the debug toolbar is enabled. This patch also fixes an issue where the page will have a height of ~1000px if the CSS is loaded after the JS executes (display:none isn't triggered before the outerHeight() calculation). I've only been able to fix this by adding a setTimeout, which is a little bit hacky.. but can't figure out how to solve it any other way. Bug: T38273 Change-Id: I1f92cb0681b7a82a5936267c120f85481a95a962 --- diff --git a/resources/src/jquery/jquery.footHovzer.js b/resources/src/jquery/jquery.footHovzer.js index de745c3360..e601ddb1b6 100644 --- a/resources/src/jquery/jquery.footHovzer.js +++ b/resources/src/jquery/jquery.footHovzer.js @@ -2,7 +2,7 @@ * @class jQuery.plugin.footHovzer */ ( function ( $ ) { - var $hovzer, footHovzer, prevHeight, newHeight; + var $hovzer, footHovzer, $spacer; function getHovzer() { if ( $hovzer === undefined ) { @@ -46,15 +46,15 @@ var $body; $body = $( 'body' ); - if ( prevHeight === undefined ) { - prevHeight = getHovzer().outerHeight( /* includeMargin = */ true ); - $body.css( 'paddingBottom', '+=' + prevHeight + 'px' ); - } else { - newHeight = getHovzer().outerHeight( true ); - $body.css( 'paddingBottom', ( parseFloat( $body.css( 'paddingBottom' ) ) - prevHeight ) + newHeight ); - prevHeight = newHeight; + if ( $spacer === undefined ) { + $spacer = $( '
' ).attr( 'id', 'jquery-foot-hovzer-spacer' ); + $spacer.appendTo( $body ); } + // Ensure CSS is applied by browser before using .outerHeight() + setTimeout( function () { + $spacer.css( 'height', getHovzer().outerHeight( /* includeMargin = */ true ) ); + }, 0 ); } };