DEV Community

mhsohag11
mhsohag11

Posted on

Answer: Call function on scroll only once

Try using .one():

$(window).one('scroll',function() {
   // Stuff
})

Or, unlink the event inside:

$(window).on('scroll',function() {
   // After Stuff
   $(window).off('scroll');
});

Guess you might need this code:

// this will check if element is in viewport

function checkVisible(elm, eval) {
  eval = eval || "object visible";
  var viewportHeight =

Top comments (0)