From fb9348dbb9dfcc105b2d9d2863ccc8859f11d50b Mon Sep 17 00:00:00 2001 From: Inez Korczynski Date: Tue, 29 Nov 2011 01:13:50 +0000 Subject: [PATCH] Use spacer element for floating toolbar instead of relaying on padding-top of next sibiling. --- modules/es/views/es.ToolbarView.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/es/views/es.ToolbarView.js b/modules/es/views/es.ToolbarView.js index 8b6c5e5219..ddbb419dcf 100644 --- a/modules/es/views/es.ToolbarView.js +++ b/modules/es/views/es.ToolbarView.js @@ -19,32 +19,29 @@ es.ToolbarView = function( $container, surfaceView ) { this.$ = $container; this.surfaceView = surfaceView; + this.$spacer = $('
'); + this.$.after( this.$spacer ); /* * This code is responsible for switching toolbar into floating mode when scrolling (with - * keyboard or mouse). It assumes that original padding-top of next sibiling element is 0 - * (if that will be a problem in future we may introduce spacer element and set it height, - * since even remembering original padding-top is not a solution because it may be set in em - * instead of px). + * keyboard or mouse). */ $window.scroll( function() { if ( _this.surfaceView.dimensions.scrollTop >= _this.surfaceView.dimensions.toolbarTop ) { if ( ! _this.$.hasClass( 'float' ) ) { var left = _this.$.offset().left, right = $window.width() - _this.$.outerWidth() - left; - _this.$.css( 'right', right ); _this.$.css( 'left', left ); - _this.$.addClass( 'float' ); - _this.$.next().css( 'padding-top', _this.$.height() ); + _this.$spacer.height( _this.$.height() ); } } else { if ( _this.$.hasClass( 'float' ) ) { _this.$.css( 'right', 0 ); _this.$.css( 'left', 0 ); _this.$.removeClass( 'float' ); - _this.$.next().css( 'padding-top', 0 ); + _this.$spacer.height(0); } } } );