fix: tweak carousel to show button change sooner (#940)

This commit is contained in:
Nolan Lawson 2019-02-05 09:54:38 -08:00 committed by GitHub
parent 7583d488a0
commit 10b14abcdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -183,7 +183,7 @@
oncreate () { oncreate () {
onCreateDialog.call(this) onCreateDialog.call(this)
this.onScroll = debounce(this.onScroll.bind(this), 100, { leading: false, trailing: true }) this.onScroll = debounce(this.onScroll.bind(this), 50, { leading: false, trailing: true })
let { scrolledItem } = this.get() let { scrolledItem } = this.get()
if (scrolledItem) { if (scrolledItem) {
@ -198,7 +198,6 @@
}, },
ondestroy () { ondestroy () {
this.teardownScroll() this.teardownScroll()
popShortcutScope('mediaDialog') popShortcutScope('mediaDialog')
}, },
store: () => store, store: () => store,
@ -262,11 +261,12 @@
this.scrollToItem(scrolledItem - 1, true) this.scrollToItem(scrolledItem - 1, true)
} }
}, },
scrollToItem (i, smooth) { scrollToItem (scrolledItem, smooth) {
this.set({ scrolledItem: scrolledItem })
let { length } = this.get() let { length } = this.get()
let { scroller } = this.refs let { scroller } = this.refs
let { scrollWidth } = scroller let { scrollWidth } = scroller
let scrollLeft = Math.floor(scrollWidth * (i / length)) let scrollLeft = Math.floor(scrollWidth * (scrolledItem / length))
if (smooth) { if (smooth) {
smoothScroll(scroller, scrollLeft, true) smoothScroll(scroller, scrollLeft, true)
} else { } else {