Created HorizontalScrollPlugin

pull/33/head
Nikan Dalvand 2019-07-29 23:40:16 +04:30
parent 251cc22dd0
commit 625233036a
1 changed files with 16 additions and 0 deletions

View File

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