Last active
June 11, 2020 18:17
-
-
Save staaky/11034178 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
/*! | |
* Disable Fresco on Mobile Browsers | |
* http://www.frescojs.com | |
*/ | |
(function($) { | |
var SUPPORTS_TOUCH = (function() { | |
try { | |
return !!(('ontouchstart' in window) || | |
window.DocumentTouch && document instanceof DocumentTouch); | |
} catch (e) { | |
return false; | |
} | |
})(); | |
// don't use this on non-touch devices | |
if (!SUPPORTS_TOUCH) return; | |
var viewport = (function() { | |
// Mobile Safari | |
if (!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)) { | |
return function() { | |
return { | |
width: window.innerWidth, | |
height: window.innerHeight | |
}; | |
}; | |
} else { | |
// everything else | |
return function() { | |
return { | |
width: $(window).width(), | |
height: $(window).height() | |
}; | |
}; | |
} | |
})(); | |
$(document).ready(function() { | |
$(window).bind('resize orientationchange', function() { | |
var vp = viewport(), | |
disable = false; | |
if ((vp.width <= 568 && vp.height <= 320) || | |
(vp.width <= 320 && vp.height <= 568)) { | |
disable = true; | |
} | |
Fresco[disable ? 'disable' : 'enable'](); | |
})(); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't appear to work with Fresco 2.3.0