Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit c8f6731

Browse files
committed
allow horizontal touch scrolling
1 parent 571675b commit c8f6731

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Scroll.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ export default class Scroll {
108108

109109
} else {
110110

111-
this.scrollPos = this.touchScroll ? -this.scrollContainer.scrollTop : -window.scrollY
111+
if (this.touchScroll) {
112+
this.scrollPos = this.horizontalScroll ? -this.scrollContainer.scrollLeft : -this.scrollContainer.scrollTop
113+
} else {
114+
this.scrollPos = -window.scrollY
115+
}
112116

113117
this.wheel = false
114118
if( Store.isTouch && this.options.disableOnTouch ) {
@@ -231,7 +235,11 @@ export default class Scroll {
231235
scrollTo( y, emitEvent = true ) {
232236
this.scrollPos = y
233237
if( Store.isTouch && this.options.disableOnTouch ) {
234-
this.scrollContainer.scrollTo(0, -this.scrollPos)
238+
if (this.horizontalScroll) {
239+
this.scrollContainer.scrollTo(-this.scrollPos, 0)
240+
} else {
241+
this.scrollContainer.scrollTo(0, -this.scrollPos)
242+
}
235243
}
236244
this.clamp()
237245
this.syncScroll = true

0 commit comments

Comments
 (0)