Scroll Animation when New Item Added to DOM


#1

Currently, I’m rendering a list of items where I’m scrolling to the bottom in an onRendered function. However, I’m having trouble figuring out how to scroll when new items are added. Any ideas?


#2

You could possibly store the number of nodes in a variable or session variable inside a tracker.auto run function. Declare another variable or session variable counting the number of nodes.

If the new variable or session variable is greater than the previous variable execute the scroll function.


#3

You could use the cursor’s observe api documented here https://docs.meteor.com/api/collections.html#Mongo-Cursor-observe

With that, you can listen as new documents are added to the client. When a new one comes, you could scroll to somewhere in the dom… perhaps render the template with a tag containing the documents id as an attribute so you can find it via jquery.