Skip to content

Commit 9c37629

Browse files
committed
Allow to disable headers hide on touch behavior
1 parent 553b585 commit 9c37629

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

js/jquery.mobile.fixHeaderFooter.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ $.fixedToolbars = (function(){
2626
touchStartEvent = supportTouch ? "touchstart" : "mousedown",
2727
touchStopEvent = supportTouch ? "touchend" : "mouseup",
2828
stateBefore = null,
29-
scrollTriggered = false;
30-
29+
scrollTriggered = false,
30+
hideOnTouchEnabled = true;
31+
3132
$(function() {
3233
$(document)
3334
.bind(touchStartEvent,function(event){
3435
if( $(event.target).closest(ignoreTargets).length ){ return; }
3536
stateBefore = currentstate;
36-
$.fixedToolbars.hide(true);
37+
if( hideOnTouchEnabled ) {
38+
$.fixedToolbars.hide(true);
39+
}
3740
})
3841
.bind('scrollstart',function(event){
3942
if( $(event.target).closest(ignoreTargets).length ){ return; } //because it could be a touchmove...
@@ -44,14 +47,22 @@ $.fixedToolbars = (function(){
4447
.bind(touchStopEvent,function(event){
4548
if( $(event.target).closest(ignoreTargets).length ){ return; }
4649
if( !scrollTriggered ){
47-
$.fixedToolbars.toggle(stateBefore);
50+
if( hideOnTouchEnabled ) {
51+
$.fixedToolbars.toggle(stateBefore);
52+
} else {
53+
$.fixedToolbars.show();
54+
}
4855
stateBefore = null;
4956
}
5057
})
5158
.bind('scrollstop',function(event){
5259
if( $(event.target).closest(ignoreTargets).length ){ return; }
5360
scrollTriggered = false;
54-
$.fixedToolbars.toggle( stateBefore == 'overlay' ? 'inline' : 'overlay' );
61+
if( hideOnTouchEnabled ) {
62+
$.fixedToolbars.toggle( stateBefore == 'overlay' ? 'inline' : 'overlay' );
63+
} else {
64+
$.fixedToolbars.show();
65+
}
5566
stateBefore = null;
5667
});
5768

@@ -195,7 +206,10 @@ $.fixedToolbars = (function(){
195206
toggle: function(from){
196207
if(from){ currentstate = from; }
197208
return (currentstate == 'overlay') ? $.fixedToolbars.hide() : $.fixedToolbars.show();
198-
}
209+
},
210+
setHideOnTouch: function(enabled) {
211+
hideOnTouchEnabled = enabled;
212+
}
199213
};
200214
})();
201215

0 commit comments

Comments
 (0)