Skip to content

Commit bb1484b

Browse files
committed
Fixed horizontal scrollToBottom error
1 parent 49f0290 commit bb1484b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ const VirtualList = Vue.component('virtual-list', {
125125
scrollToBottom () {
126126
const { shepherd } = this.$refs
127127
if (shepherd) {
128-
this.scrollToOffset(shepherd[this.isHorizontal ? 'offsetLeft' : 'offsetTop'])
128+
const offset = shepherd[this.isHorizontal ? 'offsetLeft' : 'offsetTop']
129+
this.scrollToOffset(offset)
129130

130131
// check if it's really scrolled to the bottom
131132
// maybe list doesn't render and calculate to last range
@@ -254,8 +255,8 @@ const VirtualList = Vue.component('virtual-list', {
254255
render (h) {
255256
const { header, footer } = this.$slots
256257
const { padFront, padBehind } = this.range
257-
const { rootTag, headerClass, headerTag, wrapTag, wrapClass, footerClass, footerTag } = this
258-
const padding = this.isHorizontal ? `0px ${padBehind}px 0px ${padFront}px` : `${padFront}px 0px ${padBehind}px`
258+
const { rootTag, headerClass, headerTag, wrapTag, wrapClass, footerClass, footerTag, isHorizontal } = this
259+
const padding = isHorizontal ? `0px ${padBehind}px 0px ${padFront}px` : `${padFront}px 0px ${padBehind}px`
259260

260261
return h(rootTag, {
261262
ref: 'root',
@@ -296,7 +297,11 @@ const VirtualList = Vue.component('virtual-list', {
296297

297298
// an empty element use to scroll to bottom
298299
h('div', {
299-
ref: 'shepherd'
300+
ref: 'shepherd',
301+
style: {
302+
width: isHorizontal ? '0px' : '100%',
303+
height: isHorizontal ? '100%' : '0px'
304+
}
300305
})
301306
])
302307
}

0 commit comments

Comments
 (0)