Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Can't remove event listener #26

Closed
Stantz opened this issue Jul 15, 2015 · 4 comments
Closed

Can't remove event listener #26

Stantz opened this issue Jul 15, 2015 · 4 comments

Comments

@Stantz
Copy link

Stantz commented Jul 15, 2015

I have $(target).onScreen('remove'); call at the end of my doIn method - but the doIn gets called every time the element is on screen (I'm trying to just get it to fire the first time)

@silvestreh
Copy link
Owner

The event listener is attached to the window. It should be something like $(window).onScreen('remove');

@Stantz
Copy link
Author

Stantz commented Jul 17, 2015

So I have to remove it for all elements I've attached it to? I can't just remove it for one?

@Stantz
Copy link
Author

Stantz commented Jul 19, 2015

For anyone else that also wishes to disable the onScreen event after the first onScreen and finds that the remove option is not usable since you must remove the listener from all elements...

I simple added a class inside the doIn function to the element after my logic then check for the existing of that class at the beginning of the doIn function to prevent it from running again. This allows my other elements to still be able to use the onScreen without worrying about anything firing twice.

@Stantz
Copy link
Author

Stantz commented Jul 19, 2015

Here's a code snippet to demonstrate what I mentioned above

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants