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)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay