MoveGroup.vue
3.27 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<template>
<div class="group-list" ref="groupBox">
<div class="mask"></div>
<template v-if="list.length">
<div class="move" ref="move">
<template v-for="(i, index) in list">
<div :class="['item flex', { 'group-item': index == 0 }]" :key="index">
<img :src="i.imageUrl" />
<div class="text">{{ i.name }}刚刚参加了活动</div>
</div>
</template>
</div>
</template>
</div>
</template>
<script type="text/ecmascript-6">
export default {
name: 'MoveGroup',
props: {
groupInfo: {
type: Object,
default: () => { }
},
show: {
type: Boolean,
default: false
}
},
watch: {
'show' (n) {
let { groupInfo } = this
if (n && groupInfo.groupList && groupInfo.groupList.length) this.setList(groupInfo.groupList)
}
},
data () {
return {
list: [],
speed: 0.8
}
},
mounted () {
this.$refs.groupBox.style.display = 'none'
},
methods: {
setList (list) {
this.list = list
this.$refs.groupBox.style.display = 'block'
let timer = setTimeout(() => {
this.animation(list)
clearTimeout(timer)
}, 100)
},
animation (list) {
let boxHeight = this.$refs.groupBox.offsetHeight
let [item] = document.getElementsByClassName('group-item')
let itemHeight = item.offsetHeight / 7 + item.offsetHeight
let groupHeight = `${itemHeight * list.length}`
let { speed } = this
let rule = `@keyframes rowup {
0% {transform: translateY(${boxHeight}px);}
100% {transform: translateY(-${groupHeight}px);}
}`
let sheet = document.styleSheets[0]
sheet.insertRule(rule, 0)
let duration = this.decimal(speed * list.length + (boxHeight / itemHeight * speed), 2)
this.$refs.move.style.animation = `${duration}s rowup linear infinite normal`
}
}
}
</script>
<style scoped lang="scss">
.group-list {
// visibility: hidden;
position: absolute;
left: 8px;
top: 5%;
width: 180px;
height: 80%;
overflow: hidden;
.move {
width: 100%;
}
.item {
position: relative;
display: inline-flex;
padding: 0 6px 0 3px;
box-sizing: border-box;
height: 28px;
background: rgba(0, 0, 0, 0.5);
border-radius: 17px;
margin-bottom: 4px;
font-size: 12px;
font-weight: 500;
color: #ffffff;
img {
width: 22px;
height: 22px;
border-radius: 100%;
overflow: hidden;
margin-right: 3px;
}
}
@keyframes opacity-text {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
.first {
background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 100%);
.text {
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #ffffff 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
// animation: opacity-text 5s forwards;
}
.last {
background: linear-gradient(360deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 100%);
.text {
background: linear-gradient(360deg, rgba(255, 255, 255, 0) 0%, #ffffff 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
}
.show {
visibility: visible;
}
</style>