Call scroll function only one time in jQuery


#1

I have this piece of code written in jQuery:

$('#some_element').one ('DOMMouseScroll', function (e) {//firefox
   var delta = e.originalEvent.detail;

   if (delta > 0) {
       rotateDown()
   }
});

When a user scrolls it, will call an animation.
The problem is it registers every single scroll instance, and calls the animation more than once, event with the ‘one’ function.


#2

Should be written,

.on(

?


#3

no, .one() is a handler that execute once:

http://api.jquery.com/one/


#4

Seems more like an event that one would listen for persistently, not just once. Am I missing something here?


#5

according to the documentation:

Attach a handler to an event for the elements. The handler is executed at most once per element per event type.

which seems to hold water for click event:

http://jsbin.com/mudoxis/edit?html,js,output

clicking a second time, will not give the alert.

@johncdf, if i look at the documentation:

https://developer.mozilla.org/en-US/docs/Web/Events/DOMMouseScroll

DOMMouseScroll is non-standard, is it wise to use then?