Skip to content

Commit 6bc63b7

Browse files
author
scottjehl
committed
fixed the page class name for fullscreen to include "header" or "footer". Also improved the show and hide methods so that they don't apply a transition when showing or hiding a toolbar that is fixed (not fullscreen) when the user is scrolled to the top or bottom of the viewport already.
1 parent ba484f2 commit 6bc63b7

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

js/jquery.mobile.fixedToolbar.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
// "fullscreen" overlay positioning
7474
// NOTE - this used to be only "data-fullscreen" on page element. Support both or deprecate page?
7575
if( $el.jqmData( "fullscreen" ) || $page.jqmData( "fullscreen" ) ){
76-
$el.addClass( "ui-" + tbtype + "-fullscreen" );
76+
$el.addClass( "ui-"+ tbtype +"-fullscreen" );
77+
$page.addClass( "ui-page-" + tbtype + "-fullscreen" );
7778
}
7879
// If not fullscreen, add class to page to set top or bottom padding
7980
else{
@@ -144,9 +145,18 @@
144145

145146
show: function(){
146147
var hideClass = "ui-fixed-hidden",
147-
$el = this.element;
148-
149-
if( this.options.transition && this.options.transition !== "none" ){
148+
$el = this.element,
149+
scroll = $( window ).scrollTop(),
150+
elHeight = $el.height(),
151+
pHeight = $el.closest( ".ui-page" ).height(),
152+
viewportHeight = Math.min( screen.height, $( window ).height() ),
153+
tbtype = $el.is( ".ui-header" ) ? "header" : "footer";
154+
155+
if( this.options.transition && this.options.transition !== "none" &&
156+
(
157+
( tbtype === "header" && !this.options.fullscreen && scroll > elHeight ) ||
158+
( tbtype === "footer" && !this.options.fullscreen && scroll + viewportHeight < pHeight - elHeight )
159+
) || this.options.fullscreen ){
150160
$el
151161
.removeClass( "out " + hideClass )
152162
.addClass( "in" );
@@ -159,9 +169,18 @@
159169

160170
hide: function(){
161171
var hideClass = "ui-fixed-hidden",
162-
$el = this.element;
163-
164-
if( this.options.transition && this.options.transition !== "none" && $( window ).scrollTop() > this.element.height() ){
172+
$el = this.element,
173+
scroll = $( window ).scrollTop(),
174+
elHeight = $el.height(),
175+
pHeight = $el.closest( ".ui-page" ).height(),
176+
viewportHeight = Math.min( screen.height, $( window ).height() ),
177+
tbtype = $el.is( ".ui-header" ) ? "header" : "footer";
178+
179+
if( this.options.transition && this.options.transition !== "none" &&
180+
(
181+
( tbtype === "header" && !this.options.fullscreen && scroll > elHeight ) ||
182+
( tbtype === "footer" && !this.options.fullscreen && scroll + viewportHeight < pHeight - elHeight )
183+
) || this.options.fullscreen ){
165184
$el
166185
.removeClass( "in" )
167186
.addClass( "out" )

0 commit comments

Comments
 (0)