I know what my item height is and I know the position of the item in the list, so I should be able to calculate the scroll position. However, I am not sure how to set the scroll position.
With Vuetify 2 you can use this.$vuetify.goTo($target, $options)
where $target is html element query e.g. '#targetElementId' or HTMLElement object, while all available $options you can find here.
In Vuetify 3, you can use scrollToIndex()
.
For v-virtual-scroll, you can set the scrollTop to scroll an item into view.
You can assign an id to your v-virtual-scroll element for easy selection, then set the scrollTop, like this:
let itemHeight = 48, itemIndex = 10; // set as appropriate
document.getElementById("my-scroller").scrollTop = itemHeight * itemIndex;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With