alumbo / jquery.parallax-scroll

Smooth parallax effect on vertical page scrolling
MIT License
285 stars 77 forks source link

Disable Temporarily on Mobile Version #9

Open welyanto opened 7 years ago

welyanto commented 7 years ago

Hello, is it possible to disable temporarily only on mobile version, ex: if(screen.width > 1024) { ParallaxScroll.init(); } else { $('.myclass').removeAttr("data-parallax"); }

how we can remove the data-parallax attribute temporarily and set it back once the screen width is more than 1024px? seems the ParallaxScroll.init() not trigger the removed attribute back. Any idea will be appreciated! Big Thanks :)

friizu commented 7 years ago

Smth like this ? $(window).bind('resize', function(e){ if (($(window).width() >= 1024)) { if (window.RT) clearTimeout(window.RT); window.RT = setTimeout(function() { $('.myclass').removeAttr("data-parallax"); }, 1); }

welyanto commented 7 years ago

@friizu i'm not an expert javascript/jquery but what are you trying to accomplish there? seems there some missing brackets, i got an error on the scripts

ricebandit commented 7 years ago

Just add parallax-scroll as you normally would.

Create a CSS rule:

.no-transform{ transform:none; }

With jQuery:

if($(window).width() > 768){ $('.parallax-content-id').removeClass('no-transform'); }else{ $('.parallax-content-id').addClass('no-transform'); }