mercs600 / vue2-perfect-scrollbar

Vue.js wrapper for perfect scrollbar
https://mercs600.github.io/vue2-perfect-scrollbar/
MIT License
275 stars 43 forks source link

Potential update issues (`updated` hook, `$nextTick`) #34

Closed WofWca closed 4 years ago

WofWca commented 4 years ago

Shouldn't it call ps.update() on the next tick after the updated hook has been called? See what Vue docs say: https://vuejs.org/v2/api/#updated, (page source code)

mercs600 commented 4 years ago

Ok, right it may cause some issues, did you see some troubles with that ?

WofWca commented 4 years ago

I personally did not happen to.

mercs600 commented 4 years ago

Ok, we can setup it on nextTick ofc

Dagdelo commented 4 years ago

I have this issue, I'm trying to implement an infinite scroll when the event 'ps-y-reach-start' more elements are provided, but the scroll bar jumps to the top... The position of the scrollbar should be preserved, but it's not :(

mercs600 commented 4 years ago

@Dagdelo Are you able to reproduce it on code sandbox ?

Dagdelo commented 4 years ago

Yeah. Just give-me some time.

Dagdelo commented 4 years ago

https://codesandbox.io/s/vue-perfect-scrollbar-component-local-registration-gdrg4

If we add items on top of the list, the undesirable behavior happens... But when we add on the bottom it acts as expected.

Note: if I don't call update on the PS instance, the scrollbar just updates when the user scrolls; ~if we add an @ps-y-reach-start they enter in a disgusting loop since when adding on the top the scrolls go to the top instead of preserves his position.~ (Solved with @ps-y-up and ps.reach === 'start')

Note2: when it comes to addition to the end of the list they work perfectly.

mercs600 commented 4 years ago

@Dagdelo I edited your codesandbox project and just added local perfect scrollbar component with update method on $nextTick cycle. Just check it is helpful for you ? . https://codesandbox.io/s/vue-perfect-scrollbar-component-local-registration-rhvle?fontsize=14&hidenavigation=1&theme=dark