I am trying to remove skrollr functionality on mobile screen sizes.
I have the following code in my footer.php which initiates skrollr.
<script type="text/javascript">
skrollr.init({
forceHeight: false
});
</script>
<script type="text/javascript">
//http://detectmobilebrowsers.com/ + tablets
(function(a) {
if(/android|avantgo|bada\ ... )
{
//Add skrollr mobile on mobile devices.
document.write('<script type="text/javascript" src="js/skrollr.mobile.min.js"><\/script>');
}
})(navigator.userAgent||navigator.vendor||window.opera);
</script>
I have asked around and was told to remove the initialization of skrollr in the footer.php and put code in a separate js file (mobile-fix.js)
so I replaced the script code at the bottom of footer.php with
<script type="text/javascript" src="mobile-fix.js"></script>
mobile-fix.js
$(function () {
var skrollrInstance;
var onResize = function () {
var isMobile = $(window).width() <= 767;
if (!skrollrInstance && !isMobile) {
skrollrInstance = skrollr.init({
forceHeight: false
});
} else if(skrollrInstance && isMobile) {
skrollrInstance.destroy();
skrollrInstance = null;
}
};
$(window).on('resize', onResize);
onResize();
});
I have enquened the mobile-fix.js but when removing the code from the footer.php skrollr doesn't work on any screen sizes.
Need to initiate skrollr but remove it on screen sizes > 767