Last active
October 14, 2015 11:07
-
-
Save YOzaz/e6194c9477cc0091305e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (/Android|webOS|iPhone|iPod|iPad|BlackBerry|Nokia/i.test( navigator.userAgent )) { | |
if ( bottomStickyBanner.length != 0 ) { | |
var BSBisBannerAttached = true; | |
var BSBviewScale = new FlameViewportScale(); | |
var BSBscrollHandler = function (event) { | |
if ( bottomStickyBanner.length > 0 ) | |
{ | |
// bottomStickyBanner.height(); | |
if ( BSBisBannerAttached ) { | |
bottomStickyBanner.show(); | |
} else { | |
bottomStickyBanner.hide(); | |
} | |
} | |
}; | |
var BSBscaleHandler = function (event) | |
{ | |
var screen_width = getScreenWidth(); | |
var original_scale_ratio = ( screen_width / document.documentElement.clientWidth ); | |
// screen is smaller than document - apply scaling | |
if ( original_scale_ratio < 1 ) { | |
var currentScale = BSBviewScale.getScale(); | |
if (currentScale > original_scale_ratio && BSBisBannerAttached) { | |
BSBisBannerAttached = false; | |
} else if (currentScale <= original_scale_ratio && !BSBisBannerAttached) { | |
BSBisBannerAttached = true; | |
} | |
} | |
BSBscrollHandler(); | |
}; | |
bottom_sticky_show_interval = setInterval( BSBscaleHandler, 1000 ); | |
// $( window ).bind( 'scroll.bottomSticky', BSBscaleHandler ); | |
// $( window ).bind( 'touchstart.bottomSticky', BSBscaleHandler ); | |
// $( window ).bind( 'touchmove.bottomSticky', BSBscaleHandler ); | |
// $( window ).bind( 'gesturechange.bottomSticky', BSBscaleHandler ); | |
} | |
} | |
function getScreenOrientation() { | |
var orientation = window.orientation; | |
var ret_val = 'portrait'; | |
if(orientation === 0 || orientation === 180) { | |
ret_val = 'portrait'; | |
} | |
else if(orientation === 90 || orientation === -90) { | |
ret_val = 'landscape'; | |
} | |
else { | |
// JavaScript orientation not supported. Work it out. | |
if(document.documentElement.clientWidth > document.documentElement.clientHeight) { | |
ret_val = 'landscape'; | |
} | |
else { | |
ret_val = 'portrait'; | |
} | |
} | |
return ret_val; | |
}; | |
function getScreenWidth() { | |
var ret_val = screen.width; | |
var orientation = getScreenOrientation(); | |
if(orientation === 'portrait') { | |
// Take smaller of the two dimensions | |
if(screen.width > screen.height) ret_val = screen.height; | |
} | |
else { | |
// Landscape. Take larger of the two dimensions. | |
if(screen.width < screen.height) ret_val = screen.height; | |
} | |
return ret_val; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment