This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

滚动组件增加滚动轴配置

old
宇天 2020-02-02 00:14:38 +08:00
parent 940f9acec8
commit b83c247a02
1 changed files with 19 additions and 14 deletions

View File

@ -214,7 +214,6 @@ export default class Scroll {
this.props.xw = xw
this.__X__.style.width = xw + 'px'
this.__Y__.style.height = yh + 'px'
})
@ -247,24 +246,30 @@ export default class Scroll {
deltaY = ev.deltaY / (delta / 120)
}
}
if (this.props.axis !== 'x') {
this.__BOX__.scrollTop += deltaY
this.__BOX__.scrollTop += deltaY
this.__BOX__.scrollLeft += deltaX
if (yh) {
// 修正滚动条的位置
// 滚动比例 y 滚动条的可移动距离
var fixedY = (this.__BOX__.scrollTop / (sh - oh)) * (oh - yh)
this.props.thumbY = fixedY
if (xw) {
// 修正滚动条的位置
// 滚动比例 x 滚动条的可移动距离
var fixedX = (this.__BOX__.scrollLeft / (sw - ow)) * (ow - xw)
this.props.thumbX = fixedX
this.__X__.style.transform = `translateX(${fixedX}px)`
this.__Y__.style.transform = `translateY(${fixedY}px)`
}
}
if (yh) {
var fixedY = (this.__BOX__.scrollTop / (sh - oh)) * (oh - yh)
this.props.thumbY = fixedY
if (this.props.axis !== 'y') {
this.__BOX__.scrollLeft += deltaX
this.__Y__.style.transform = `translateY(${fixedY}px)`
if (xw) {
// 修正滚动条的位置
// 滚动比例 x 滚动条的可移动距离
var fixedX = (this.__BOX__.scrollLeft / (sw - ow)) * (ow - xw)
this.props.thumbX = fixedX
this.__X__.style.transform = `translateX(${fixedX}px)`
}
}
})