javascript - Enable scroll within a function -
when use scrollwheel
i'm incremeting currentslide
one, when currentslide === 2
red div going , want enable scrolling body. see bind function returning false
. tried put conditions on , return true
when currentslide === 2
apparently won't work.
can explain me how fix that?
var currentslide = 0; function scrolldown() { console.log('scroll down', currentslide); if(currentslide < 3) { currentslide += 1; } if(currentslide === 3) { $('#el').addclass('hide'); } }
i'm totally not sure trying question , expected result quite unclear
i made code following
var currentslide = 0; function scrolldown() { console.log('scroll down', currentslide); if(currentslide < 10) { currentslide += 1; return false; } if(currentslide === 10) { $('#el').addclass('hide'); } } $(window).on('dommousescroll', function(e) { if (e.originalevent.detail > 0) { return scrolldown(); } }) .on('mousewheel', function(e) { if (e.originalevent.wheeldelta < 0) { return scrolldown(); } });
by using on(which should) , having scrolldown returning boolean false if not go, , return nothing if there's nothing do.
Comments
Post a Comment