amsik / liquor-tree

Tree component based on Vue.js
MIT License
398 stars 95 forks source link

Scroll to selected node #239

Open bajki opened 3 years ago

bajki commented 3 years ago

Hi, if i have 100 nodes, how to scroll to selected node on initial render?

Thanks

FRizZL commented 3 years ago

I'm having this same problem. It seems that we need an event when the complete tree is fully rendered. For the scrolling support I use vue-scrollto, which seems to work when the tree is rendered instantly.

I made this (foolish) workaround for the time being (just put in in the mounted() method, after the async data is loaded).

setTimeout(() => {
  VueScrollTo.scrollTo('#YOUR_ID', 500, {
    container: '#tree-container',
    offset: -100,
  })
}, 1000)

Keep in mind that the container has be scrollable.