stutrek / scrollmonitor

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

Can't create a new watcher after destroying one #84

Closed bryanh210 closed 3 years ago

bryanh210 commented 5 years ago

Hello, currently I've destroyed an old watcher and made a new one but it doesn't seem like a new one is created / all future watchers are prevented from creating. Could you look into it? If this is not possible, could you elaborate on how to use off/on/one? There is not much documentation to it.

dearsina commented 5 years ago

I have the same problem. I use the watcher to only load additional rows in a large table when the user reaches the end of their currently loaded rows. When all the rows have been loaded and displayed to the user, the listener is destroyed. If the user changes a search parameter and restart the loading, I am unable to create a new one (without F5, refreshing the window).

The way I'm currently going about it is to create a variable that is toggled (on when there are rows left to display, off when all the rows have been displayed) as a substitute for the listener. So the listener is always listening, but only reacting if the variable is toggled on.

Yes, it's a total hack, but it works.

stutrek commented 5 years ago

Can you post some code?

bryanh210 commented 4 years ago

Damn, I solved this problem 2 years ago but thank you for the update!

On Sat, Sep 14, 2019 at 12:01 PM Stu Kabakoff notifications@github.com wrote:

Can you post some code?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/stutrek/scrollMonitor/issues/84?email_source=notifications&email_token=ACONJX4PQH4GLNC47EFZOMTQJUDF7A5CNFSM4F2PG572YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6W6TIQ#issuecomment-531491234, or mute the thread https://github.com/notifications/unsubscribe-auth/ACONJX7SWO5VWQ66W2DBUETQJUDF7ANCNFSM4F2PG57Q .