forked from jquery-archive/jquery-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.mobile.fixHeaderFooter.native.js
63 lines (47 loc) · 1.74 KB
/
jquery.mobile.fixHeaderFooter.native.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* jQuery Mobile Framework : "fixHeaderFooter" native plugin - Behavior for "fixed" headers,footers, and scrolling inner content
* Copyright (c) jQuery Project
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
(function( $, undefined ) {
// Enable touch overflow scrolling when it's natively supported
$.mobile.touchOverflowEnabled = false;
// Enabled zoom when touch overflow is enabled. Can cause usability issues, unfortunately
$.mobile.touchOverflowZoomEnabled = false;
$( document ).bind( "pagecreate", function( event ) {
if( $.support.touchOverflow && $.mobile.touchOverflowEnabled ){
var $target = $( event.target ),
scrollStartY = 0;
if( $target.is( ":jqmData(role='page')" ) ){
$target.each(function() {
var $page = $( this ),
$fixies = $page.find( ":jqmData(role='header'), :jqmData(role='footer')" ).filter( ":jqmData(position='fixed')" ),
fullScreen = $page.jqmData( "fullscreen" ),
$scrollElem = $fixies.length ? $page.find( ".ui-content" ) : $page;
$page.addClass( "ui-mobile-touch-overflow" );
$scrollElem.bind( "scrollstop", function(){
if( $scrollElem.scrollTop() > 0 ){
window.scrollTo( 0, $.mobile.defaultHomeScroll );
}
});
if( $fixies.length ){
$page.addClass( "ui-native-fixed" );
if( fullScreen ){
$page.addClass( "ui-native-fullscreen" );
$fixies.addClass( "fade in" );
$( document ).bind( "vclick", function(){
$fixies
.removeClass( "ui-native-bars-hidden" )
.toggleClass( "in out" )
.animationComplete(function(){
$(this).not( ".in" ).addClass( "ui-native-bars-hidden" );
});
});
}
}
});
}
}
});
})( jQuery );