Prinzhorn / skrollr

Stand-alone parallax scrolling library for mobile (Android + iOS) and desktop. No jQuery. Just plain JavaScript (and some love).
http://prinzhorn.github.io/skrollr/
MIT License
18.53k stars 3.5k forks source link

bug on android #795

Open wwwebman opened 8 years ago

wwwebman commented 8 years ago

init of scrollr make some bug: Make init and destroy in simple way:

if (viewportWidth >= mobile) { skrollr.init({ forceHeight: false, smoothScrolling: true }); }else { skrollr.init().destroy(); }

But: When i scroll page bottom sometimes happen returning or jumping top. When i dont destroy, but just init:

if (viewportWidth >= mobile) { skrollr.init({ forceHeight: false, smoothScrolling: true });

Everithing is ok. But onresize i need destroy/init on other devices. My question: can i make destroy without init, I meen:

skrollr.init().destroy();

And it must be based on checking viewport width, but not device type.

Thanks a lot.

RaphaelHofer commented 7 years ago

use .get() otherwise you initialize a skrollr instance on mobile devices instead of destroying one.

if (viewportWidth >= mobile) { 
    skrollr.init({ 
        forceHeight: false, 
        smoothScrolling: true 
    }); 
} else if (typeof skrollr.get() !== 'undefined') { 
    skrollr.get().destroy(); 
}