Added a fix for homepage scroll on touch devices

pull/40/head
Nikan Dalvand 2019-07-31 22:59:33 +04:30
parent ccfee620fe
commit 7113f66802
1 changed files with 7 additions and 5 deletions

View File

@ -3,15 +3,17 @@ import Scrollbar from 'smooth-scrollbar'
export default class HorizontalScrollPlugin extends Scrollbar.ScrollbarPlugin {
static pluginName = 'horizontalScroll';
transformDelta (delta, fromEvent) {
console.log(fromEvent.type)
const { x, y } = delta
if (!this.scrollbar.options.horizontal) {
return {
y: y,
x: 0
}
}
if (!/wheel/.test(fromEvent.type)) {
return delta
}
// @see: https://github.com/idiotWu/smooth-scrollbar/issues/181
if (!this.scrollbar.options.horizontal) {
return
}
const { x, y } = delta
return {
y: 0,
x: Math.abs(x) > Math.abs(y) ? x : y