javascript - Run script upon scroll, but only once -
i'm using introjs on website. people can start tour clicking button, want auto-start when visitors scroll down. made function this, keeps starting tour flipping entire webpage out:
window.onscroll = function() {tourstart()}; function tourstart() { if (document.body.scrolltop > 50) { introjs().start(); } } how can make run once?
thank in advance!
remove handler when start tour:
function tourstart() { if (document.body.scrolltop > 50) { window.onscroll = null; introjs().start(); } }
Comments
Post a Comment