sadais-piui 1.2.7-beta150 → 1.2.7-beta152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
:style="[customStyle]"
|
|
4
|
+
class="pi-marquee-pure-css"
|
|
5
|
+
:class="[customClass, directionClass]"
|
|
6
|
+
>
|
|
7
|
+
<view
|
|
8
|
+
class="marquee-content"
|
|
9
|
+
:class="animationClass"
|
|
10
|
+
:style="animationStyle"
|
|
11
|
+
>
|
|
12
|
+
<!-- 第一组内容 -->
|
|
13
|
+
<view class="marquee-group">
|
|
14
|
+
<view
|
|
15
|
+
v-for="(item, index) in items"
|
|
16
|
+
:key="`first-${index}`"
|
|
17
|
+
class="marquee-item"
|
|
18
|
+
>
|
|
19
|
+
<slot name="item" :item="item" :index="index">
|
|
20
|
+
<text>{{ item }}</text>
|
|
21
|
+
</slot>
|
|
22
|
+
</view>
|
|
23
|
+
</view>
|
|
24
|
+
|
|
25
|
+
<!-- 第二组内容(用于无缝循环) -->
|
|
26
|
+
<view class="marquee-group">
|
|
27
|
+
<view
|
|
28
|
+
v-for="(item, index) in items"
|
|
29
|
+
:key="`second-${index}`"
|
|
30
|
+
class="marquee-item"
|
|
31
|
+
>
|
|
32
|
+
<slot name="item" :item="item" :index="index">
|
|
33
|
+
<text>{{ item }}</text>
|
|
34
|
+
</slot>
|
|
35
|
+
</view>
|
|
36
|
+
</view>
|
|
37
|
+
</view>
|
|
38
|
+
</view>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script>
|
|
42
|
+
import { getConfig } from '../../config'
|
|
43
|
+
|
|
44
|
+
const TAG = 'PiMarqueePureCss'
|
|
45
|
+
const { marqueePureCss } = getConfig()
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
name: 'PiMarqueePureCss',
|
|
49
|
+
props: {
|
|
50
|
+
// 自定义样式
|
|
51
|
+
customStyle: {
|
|
52
|
+
type: Object,
|
|
53
|
+
default() {
|
|
54
|
+
return marqueePureCss.customStyle || {}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
// 自定义样式类
|
|
58
|
+
customClass: {
|
|
59
|
+
type: String,
|
|
60
|
+
default() {
|
|
61
|
+
return marqueePureCss.customClass || ''
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
// 滚动方向: 'left', 'right', 'up', 'down'
|
|
65
|
+
direction: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: marqueePureCss.direction,
|
|
68
|
+
validator: value => ['left', 'right', 'up', 'down'].includes(value)
|
|
69
|
+
},
|
|
70
|
+
// 动画持续时间(秒)
|
|
71
|
+
duration: {
|
|
72
|
+
type: [Number, String],
|
|
73
|
+
default: marqueePureCss.duration
|
|
74
|
+
},
|
|
75
|
+
// 动画速度曲线
|
|
76
|
+
timingFunction: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: marqueePureCss.timingFunction
|
|
79
|
+
},
|
|
80
|
+
// 是否暂停动画
|
|
81
|
+
paused: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: marqueePureCss.paused
|
|
84
|
+
},
|
|
85
|
+
// 轮播数据
|
|
86
|
+
items: {
|
|
87
|
+
type: Array,
|
|
88
|
+
default: () => marqueePureCss.items
|
|
89
|
+
},
|
|
90
|
+
// 每个item之间的间距(单位:rpx)
|
|
91
|
+
itemGap: {
|
|
92
|
+
type: [Number, String],
|
|
93
|
+
default: marqueePureCss.itemGap
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
computed: {
|
|
97
|
+
directionClass() {
|
|
98
|
+
return `direction-${this.direction}`
|
|
99
|
+
},
|
|
100
|
+
animationClass() {
|
|
101
|
+
return `marquee-${this.direction}`
|
|
102
|
+
},
|
|
103
|
+
animationStyle() {
|
|
104
|
+
const style = {
|
|
105
|
+
animationDuration: `${this.duration}s`,
|
|
106
|
+
animationTimingFunction: this.timingFunction,
|
|
107
|
+
animationPlayState: this.paused ? 'paused' : 'running'
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 如果有间距,添加gap样式
|
|
111
|
+
if (this.itemGap && this.itemGap > 0) {
|
|
112
|
+
if (['left', 'right'].includes(this.direction)) {
|
|
113
|
+
style.gap = `${this.itemGap}rpx`
|
|
114
|
+
} else {
|
|
115
|
+
style.rowGap = `${this.itemGap}rpx`
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return style
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
methods: {
|
|
123
|
+
/**
|
|
124
|
+
* 暂停动画
|
|
125
|
+
*/
|
|
126
|
+
pause() {
|
|
127
|
+
this.$emit('update:paused', true)
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 恢复动画
|
|
132
|
+
*/
|
|
133
|
+
resume() {
|
|
134
|
+
this.$emit('update:paused', false)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
</script>
|
|
139
|
+
|
|
140
|
+
<style lang="scss" scoped>
|
|
141
|
+
.pi-marquee-pure-css {
|
|
142
|
+
overflow: hidden;
|
|
143
|
+
position: relative;
|
|
144
|
+
|
|
145
|
+
&.direction-left,
|
|
146
|
+
&.direction-right {
|
|
147
|
+
width: 100%;
|
|
148
|
+
white-space: nowrap;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&.direction-up,
|
|
152
|
+
&.direction-down {
|
|
153
|
+
height: 100%;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.marquee-content {
|
|
158
|
+
display: flex;
|
|
159
|
+
|
|
160
|
+
.direction-left &,
|
|
161
|
+
.direction-right & {
|
|
162
|
+
flex-direction: row;
|
|
163
|
+
width: fit-content;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.direction-up &,
|
|
167
|
+
.direction-down & {
|
|
168
|
+
flex-direction: column;
|
|
169
|
+
height: fit-content;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.marquee-group {
|
|
174
|
+
display: flex;
|
|
175
|
+
flex-shrink: 0;
|
|
176
|
+
|
|
177
|
+
.direction-left &,
|
|
178
|
+
.direction-right & {
|
|
179
|
+
flex-direction: row;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.direction-up &,
|
|
183
|
+
.direction-down & {
|
|
184
|
+
flex-direction: column;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.marquee-item {
|
|
189
|
+
flex-shrink: 0;
|
|
190
|
+
display: flex;
|
|
191
|
+
align-items: center;
|
|
192
|
+
|
|
193
|
+
.direction-left &,
|
|
194
|
+
.direction-right & {
|
|
195
|
+
display: inline-flex;
|
|
196
|
+
white-space: nowrap;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.direction-up &,
|
|
200
|
+
.direction-down & {
|
|
201
|
+
width: 100%;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* 左滚动动画 */
|
|
206
|
+
.marquee-left {
|
|
207
|
+
animation: marquee-scroll-left infinite;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@keyframes marquee-scroll-left {
|
|
211
|
+
0% {
|
|
212
|
+
transform: translateX(0);
|
|
213
|
+
}
|
|
214
|
+
100% {
|
|
215
|
+
transform: translateX(-50%);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/* 右滚动动画 */
|
|
220
|
+
.marquee-right {
|
|
221
|
+
animation: marquee-scroll-right infinite;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@keyframes marquee-scroll-right {
|
|
225
|
+
0% {
|
|
226
|
+
transform: translateX(-50%);
|
|
227
|
+
}
|
|
228
|
+
100% {
|
|
229
|
+
transform: translateX(0);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* 上滚动动画 */
|
|
234
|
+
.marquee-up {
|
|
235
|
+
animation: marquee-scroll-up infinite;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
@keyframes marquee-scroll-up {
|
|
239
|
+
0% {
|
|
240
|
+
transform: translateY(0);
|
|
241
|
+
}
|
|
242
|
+
100% {
|
|
243
|
+
transform: translateY(-50%);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* 下滚动动画 */
|
|
248
|
+
.marquee-down {
|
|
249
|
+
animation: marquee-scroll-down infinite;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@keyframes marquee-scroll-down {
|
|
253
|
+
0% {
|
|
254
|
+
transform: translateY(-50%);
|
|
255
|
+
}
|
|
256
|
+
100% {
|
|
257
|
+
transform: translateY(0);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* 响应式处理 */
|
|
262
|
+
@media screen and (max-width: 750px) {
|
|
263
|
+
.marquee-item {
|
|
264
|
+
font-size: 28rpx;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
</style>
|
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
:style="[
|
|
27
27
|
{
|
|
28
28
|
borderRadius: `${borderRadius}rpx`,
|
|
29
|
-
transform:
|
|
30
|
-
effect3d && val !== index ? 'scaleY(0.9)' : 'scaleY(1)',
|
|
29
|
+
transform: effect3d && val !== index ? 'scale(0.9)' : 'scale(1)',
|
|
31
30
|
padding: effect3d && val !== index ? '0 20rpx' : 0
|
|
32
31
|
}
|
|
33
32
|
]"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
// 滚动方向: 'left', 'right', 'up', 'down'
|
|
3
|
+
direction: 'left',
|
|
4
|
+
// 动画持续时间(秒)
|
|
5
|
+
duration: 15,
|
|
6
|
+
// 动画速度曲线: linear, ease, ease-in, ease-out, ease-in-out
|
|
7
|
+
timingFunction: 'linear',
|
|
8
|
+
// 是否暂停动画
|
|
9
|
+
paused: false,
|
|
10
|
+
// 自定义样式
|
|
11
|
+
customStyle: {},
|
|
12
|
+
// 自定义样式类
|
|
13
|
+
customClass: '',
|
|
14
|
+
// 轮播数据
|
|
15
|
+
items: [],
|
|
16
|
+
// 每个item之间的间距(单位:rpx)
|
|
17
|
+
itemGap: 0
|
|
18
|
+
}
|