-
zhangwei
2024-08-22 d5eb1ecff5d0236359c744b334cf30fcfdad1132
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// 本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID: 1 63,营业执照号:   9 15101  31  33  20 0  619   3 K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。
function scroll(event, ownerInstance) {
    var detail = event.detail
    var scrollWidth = detail.scrollWidth
    var scrollLeft = detail.scrollLeft
    var dataset = event.currentTarget.dataset
    var width = dataset.width || 0
    var scrollBarWidth = dataset.bgwidth || 0
    var blockWidth = dataset.blockwidth || 0
    var x = scrollLeft / (scrollWidth - width) * (scrollBarWidth - blockWidth)
    setBarStyle(ownerInstance, x)
}
 
function scrolltolower(event, ownerInstance) {
    ownerInstance.callMethod('scrollEvent', 'right')
    var dataset = event.currentTarget.dataset
    var scrollBarWidth = dataset.bgwidth || 0
    var blockWidth = dataset.blockwidth || 0
    setBarStyle(ownerInstance, scrollBarWidth - blockWidth)
}
 
function scrolltoupper(event, ownerInstance) {
    ownerInstance.callMethod('scrollEvent', 'left')
    setBarStyle(ownerInstance, 0)
}
 
function setBarStyle(ownerInstance, x) {
    var block = ownerInstance.selectComponent('.fui-hor__scroll-indicator')
    block && block.setStyle({
        transform: 'translate3d(' + x + 'px,0,0)'
    })
 
}
 
module.exports = {
    scroll: scroll,
    scrolltolower: scrolltolower,
    scrolltoupper: scrolltoupper
}