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
| <template>
| <!--本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID:1 6 3,营业执照号: 915 1013 1 3 32 0 06 1 93 K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。-->
| <view class="fui-spin__wrap" :style="{width:width?width+'rpx':'auto',height:height?height+'rpx':'auto'}"
| ref="fui_spin_ani">
| <slot></slot>
| </view>
| </template>
|
| <script>
| // #ifdef APP-NVUE
| const animation = uni.requireNativePlugin('animation');
| // #endif
| export default {
| name: "fui-spin",
| props: {
| width: {
| type: [Number, String],
| default: 0
| },
| height: {
| type: [Number, String],
| default: 0
| }
| },
| data() {
| return {
| // #ifdef APP-NVUE
| deg: 0,
| stop: false
| // #endif
| };
| },
| // #ifdef APP-NVUE
| mounted() {
| this.$nextTick(() => {
| setTimeout(() => {
| this.deg += 360;
| this._animation()
| }, 50)
| })
| },
| // #endif
| // #ifdef APP-NVUE
| // #ifndef VUE3
| beforeDestroy() {
| this.deg = 0;
| this.stop = true;
| },
| // #endif
| // #ifdef VUE3
| beforeUnmount() {
| this.deg = 0;
| this.stop = true;
| },
| // #endif
| // #endif
| methods: {
| // #ifdef APP-NVUE
| _animation() {
| if (!this.$refs['fui_spin_ani'] || this.stop) return;
| animation.transition(
| this.$refs['fui_spin_ani'].ref, {
| styles: {
| transform: `rotate(${this.deg}deg)`
| },
| duration: 800, //ms
| timingFunction: 'linear',
| iterationCount: 'infinite',
| needLayout: false,
| delay: 0 //ms
| }, () => {
| this.deg += 360;
| this._animation()
| }
| );
| }
| // #endif
| }
| }
| </script>
|
| <style scoped>
| .fui-spin__wrap {
| /* #ifndef APP-NVUE */
| display: inline-flex;
| /* #endif */
| align-items: center;
| justify-content: center;
| flex-direction: row;
|
| /* #ifndef APP-NVUE */
| animation: spin 0.85s linear infinite;
| /* #endif */
| }
|
|
| /* #ifndef APP-NVUE */
| @-webkit-keyframes spin {
| 0% {
| transform: rotate(0deg);
| }
|
| 100% {
| transform: rotate(360deg);
| }
| }
|
| @keyframes spin {
| 0% {
| transform: rotate(0deg);
| }
|
| 100% {
| transform: rotate(360deg);
| }
| }
|
| /* #endif */
| </style>
|
|