MoveGroup.js
1.28 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// pages/crowdfunding/components/MoveGroup/MoveGroup.js
import util from '~/utils/util'
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
value: false,
observer: function (n) {
let { groupList } = this.data.groupInfo
if (n && groupList && groupList.length) {
this.setData({
list: groupList
})
this.animation(groupList)
}
}
},
groupInfo: {
type: Object,
value: () => { }
}
},
/**
* 组件的初始数据
*/
data: {
list: [],
speed: 0.8,
displayNums: 1
},
/**
* 组件的方法列表
*/
methods: {
animation(list) {
let _this = this
var query = this.createSelectorQuery()
query.select('#groupBox').boundingClientRect()
query.select('.group-item').boundingClientRect()
query.exec(function (res) {
const boxHeight = res[0].height
const itemHeight = res[1].height
if (boxHeight < itemHeight) {
let timer = setTimeout(() => {
_this.animation(list)
clearTimeout(timer)
}, 300)
} else {
_this.setData({
displayNums: res[0].height / res[1].height
})
}
})
}
}
})