jeremenichelli / hunt

👻 Minimal library to observe nodes entering and leaving the viewport
https://jeremenichelli.github.io/hunt
MIT License
342 stars 10 forks source link

stop hunting if persist ist false and out is noop #18

Closed DanielRuf closed 7 years ago

DanielRuf commented 7 years ago

I have the case that I have hunted elements. Some of them never trigger out as they are always visible in many cases.

The out callback is not defined in this case. I have to create an array and set the visible state in the enter callback using the index of this array, use Array.every and manually call disconnect as they never trigger out.

So it is not necessary to still hunt the elements after this as just the enter callback is used.

You can see on https://sicherheit.daniel-ruf.de how I solved this without this fix.

jeremenichelli commented 7 years ago

Awesome fix, haven't thought about it, will review this weekend more closely and merge.

Thanks @DanielRuf!