File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 4242 max =" 500000"
4343 > buffer
4444 </span >
45+ <span >
46+ <button @mousedown =" $refs.scroller.scrollToItem(scrollTo)" >Scroll To: </button >
47+ <input
48+ v-model.number =" scrollTo"
49+ type =" number"
50+ min =" 0"
51+ :max =" list.length - 1"
52+ >
53+ </span >
4554 <span >
4655 <button @mousedown =" renderScroller = !renderScroller" >Toggle render</button >
4756 <button @mousedown =" showScroller = !showScroller" >Toggle visibility</button >
@@ -113,6 +122,7 @@ export default {
113122 enableLetters: true ,
114123 pageMode: false ,
115124 pageModeFullPage: true ,
125+ scrollTo: 100 ,
116126 }),
117127
118128 computed: {
Original file line number Diff line number Diff line change @@ -573,11 +573,23 @@ export default {
573573 },
574574
575575 scrollToPosition (position ) {
576- if (this .direction === ' vertical' ) {
577- this .$el .scrollTop = position
578- } else {
579- this .$el .scrollLeft = position
576+ const direction = this .direction === ' vertical'
577+ ? { scroll: ' scrollTop' , start: ' top' , size: ' height' }
578+ : { scroll: ' scrollLeft' , start: ' left' , size: ' width' }
579+
580+ if (this .pageMode ) {
581+ const viewportEl = ScrollParent (this .$el )
582+ // HTML doesn't overflow like other elements
583+ const scrollTop = viewportEl .tagName === ' HTML' ? 0 : viewportEl[direction .scroll ]
584+ const viewport = viewportEl .getBoundingClientRect ()
585+
586+ const scroller = this .$el .getBoundingClientRect ()
587+ const beginningOfViewport = scroller[direction .start ] - viewport[direction .start ]
588+ viewportEl[direction .scroll ] = position + scrollTop + beginningOfViewport
589+ return
580590 }
591+
592+ this .$el [direction .scroll ] = position
581593 },
582594
583595 itemsLimitError () {
You can’t perform that action at this time.
0 commit comments