stutrek / scrollmonitor

A simple and fast API to monitor elements as you scroll
MIT License
3.3k stars 244 forks source link

.off and .destroy fn's broke? #49

Closed dontboyle closed 8 years ago

dontboyle commented 8 years ago

var monitor = scrollMonitor.create(someElement); .on('enterViewport', onEnterFunction); //works great

.off('enterViewport') //doesn't work //keeps calling .on('enterViewport', onEnter);

Same with destroy - doesn't work.

Thanks for any feedback

stutrek commented 8 years ago

you have to tell it which callback you want to remove, it doesn't clear them all out like jquery does.

You can monitor.destory() if you want to destroy it.

dontboyle commented 8 years ago

So I have to pass in the onEnterFunction to the .off??

Got it thanks!

dontboyle commented 8 years ago

@stutrek

Hey I appreciate the feedback so far - just wanted to let you know that the above is still not working properly. - Off does so I'm good to go, thought i'd leave this here however.

var monitor = scrollMonitor.create(someElement);
monitor.on('enterViewport', onEnter); //works
//monitor.off('enterViewport', onEnter); //works
monitor.destroy(); //doesn't work