Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var ipadStickyHeader = function() {
- var ipad = navigator.userAgent.match(/iPad/i);
- var landscapeOrientationCheck = window.matchMedia('(orientation: landscape)');
- var scrollPos;
- landscapeOrientationCheck.addListener(getOrientationValue);
- function getOrientationValue (mediaQuery) {
- // check if device is ipad in landscape mode
- if (ipad && mediaQuery.matches) {
- if ($('input[type="text"]:not(".mh-sf-input")').is(':focus')) {
- isSticky();
- }
- $( 'body' ).on( 'focus', 'input[type="text"]:not(".mh-sf-input")', isSticky);
- $( 'body' ).on( 'blur', 'input[type="text"]:not(".mh-sf-input")', removeStickyClass);
- w.on('touchmove', scrolling);
- }
- function scrolling() {
- scrollPos = w.scrollTop();
- if (scrollPos < mainHeaderHeight) {
- removeStickyClass();
- } else {
- isSticky();
- }
- }
- function removeStickyClass() {
- $('.main-header').removeClass('sticky-main-header-fix');
- $('.main-header').css({
- top: 0,
- position: 'relative'
- });
- }
- function isSticky() {
- $('.main-header').addClass('sticky-main-header-fix');
- $('.sticky-main-header-fix').css({
- top: mainHeaderHeight,
- position: 'absolute'
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement