mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-17 06:20:26 +00:00
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
/*
|
|
* "fixHeaderFooter" native plugin - Behavior for "fixed" headers,footers, and scrolling inner content
|
|
*/
|
|
|
|
(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 );
|