I've followed the instructions on the Skrollr website as well as in this question (How to fix Skrollr on Mobile?). My issue is that when I add id="scrollr-body" to my body tag, the scrolling stops working everywhere.
This is the code I'm using in the footer:
<script type="text/javascript">
skrollrCheck = function() {
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
if(winWidth >= 768) {
if(document.body.id !== 'skrollr-body') {
document.body.id = 'skrollr-body';
// Init Skrollr
skrollr.init({
forceHeight: false,//disable setting height on body
mobileDeceleration:0.04,
smoothScrolling:true,
render: function(data) {
//Debugging - Log the current scroll position.
//console.log('data.curTop: ' + data.curTop);
}
});
}
if(winWidth > winHeight) {
console.log('orientation is landscape');
skrollr.get().refresh();
} else if (winWidth < winHeight) {
console.log('orientation is portrait');
skrollr.get().refresh();
}
} else if (winWidth < 768){
// Destroy skrollr for screens less than 600px
if(document.body.id === 'skrollr-body') {
skrollr.init().destroy();
document.body.id = '';
}
}
};
//Initialize skrollr, but only if it exists.
if(typeof skrollr !== typeof undefined){
// INITIALIZE
window.onload = skrollrCheck();
window.addEventListener('resize', skrollrCheck);//listens for resize,
and refreshes skrollr
window.addEventListener('orientationchange', skrollrCheck);//listens
for
orientation change, and refreshes skrollr
console.log('skrollr active!');
} else {
console.log('skrollr is did not load.');
}
</script>
If I remove the scrollr-body id from the body tag, parallax scrolling works great on desktop, but scrolling doesn't work at all on iPad. If I add it in, parallax disappears from everywhere, but iPad works fine. Any ideas? Thanks!