hakubo / Sloth

Library to lazy initialize components of a webpage when they become visible
http://hakubo.github.com/Sloth/
MIT License
56 stars 5 forks source link

Keep tracking elements after they appear in view. #4

Closed mikedidthis closed 11 years ago

mikedidthis commented 11 years ago

Is it possible to add an option to specify if you want the element removing from branches once its been scrolled into view?

The purpose is an element may come into view, go out of view and then come back in again.

Thanks

hakubo commented 11 years ago

I agree it might come handy from time to time.

Let me know if you have time to do this. If not I'll try to add this this week.

Thanks!

mikedidthis commented 11 years ago

I tried to do it myself, but sadly failed. I believe the key is branches.splice(i, 1);.

If I comment this out, it works as intended, but with an unforeseen issue:

1) Due to branch no longer being removed from branches, the callback fires every time you scroll (with the element still in view).

This isn't a design issue btw, as the function was never designed to work this way. What about pushing an element back into branches once its gone out of view?