Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to update scrollama dynamically #8

Closed
travbus opened this issue Feb 18, 2019 · 2 comments
Closed

Is it possible to update scrollama dynamically #8

travbus opened this issue Feb 18, 2019 · 2 comments

Comments

@travbus
Copy link

travbus commented Feb 18, 2019

I"m trying to use scrollama to make a dynamic infinite scoll list by tracking the index in the handler. Problem is when I update my looped array feedPosts, scrollama only works with the initial array of objects. So to get around that I rerendered scrollama by updating :key="componentKey" to + 1 after array is updated it rerenders scrollama and new data is working with it. Unfortunately it also resets the scroll to the top and the scrolloma flashes in the process.

The question is it possible to update scrollama dynamically without rerender? Thanks!!

`
<Scrollama :debug="true" :offset="0.8" v-if="feedPosts.length" @step-enter="handleScroll" :once="true" class="container" :key="componentKey" >

some content>
`

@vgshenoy
Copy link
Owner

In the latest version (1.1.1), you can try calling an internal method setup() to re-setup scroll interactions and avoid a re-render

<Scrollama ref="scrollama" ...>
...
</Scrollama>

and once your array is updated

this.$refs.scrollama.setup()

@travbus
Copy link
Author

travbus commented Feb 19, 2019

It actually did work I must have had two many hoots. But I did realize I've been trying to replace an entire array with an updated one when I should push one item onto the array at a time. Thanks so much for the help. Kisses

https://codesandbox.io/s/4270xl6oz0

@travbus travbus closed this as completed Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants