@kengic/uni 0.5.1 → 0.5.2-beta.0
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.
- package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
- package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
- package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
- package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
- package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
- package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
- package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
- package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
- package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
- package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
- package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
- package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
- package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
- package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
- package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
- package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
- package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
- package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
- package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
- package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
- package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
- package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
- package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
- package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
- package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
- package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
- package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
- package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
- package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
- package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
- package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
- package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
- package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
- package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
- package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
- package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
- package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
- package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
- package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
- package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
- package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
- package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
- package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
- package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
- package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
- package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
- package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
- package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
- package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
- package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
- package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
- package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
- package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
- package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
- package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
- package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
- package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
- package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
- package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
- package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
- package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
- package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
- package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
- package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
- package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
- package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
- package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
- package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
- package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
- package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
- package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
- package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
- package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
- package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
- package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
- package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
- package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
- package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
- package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
- package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
- package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
- package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
- package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
- package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
- package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
- package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
- package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
- package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
- package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
- package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
- package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
- package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
- package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
- package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
- package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
- package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
- package/dist/uni/uni-ui/uni-scss/package.json +73 -73
- package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
- package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
- package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
- package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
- package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
- package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
- package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
- package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
- package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
- package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
- package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
- package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
- package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
- package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
- package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
- package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
- package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
- package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
- package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
- package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
- package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
- package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
- package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
- package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
- package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
- package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +392 -313
- package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
- package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
- package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
- package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
- package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
- package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
- package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
- package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
- package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
- package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
- package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
- package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
- package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
- package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
- package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
- package/package.json +1 -1
|
@@ -1,281 +1,283 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<view v-if="isShow || onceRender" v-show="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"
|
|
3
|
+
><slot></slot
|
|
4
|
+
></view>
|
|
3
5
|
</template>
|
|
4
6
|
|
|
5
7
|
<script>
|
|
6
|
-
import { createAnimation } from './createAnimation'
|
|
8
|
+
import { createAnimation } from './createAnimation';
|
|
7
9
|
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export default {
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Transition 过渡动画
|
|
12
|
+
* @description 简单过渡动画组件
|
|
13
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=985
|
|
14
|
+
* @property {Boolean} show = [false|true] 控制组件显示或隐藏
|
|
15
|
+
* @property {Array|String} modeClass = [fade|slide-top|slide-right|slide-bottom|slide-left|zoom-in|zoom-out] 过渡动画类型
|
|
16
|
+
* @value fade 渐隐渐出过渡
|
|
17
|
+
* @value slide-top 由上至下过渡
|
|
18
|
+
* @value slide-right 由右至左过渡
|
|
19
|
+
* @value slide-bottom 由下至上过渡
|
|
20
|
+
* @value slide-left 由左至右过渡
|
|
21
|
+
* @value zoom-in 由小到大过渡
|
|
22
|
+
* @value zoom-out 由大到小过渡
|
|
23
|
+
* @property {Number} duration 过渡动画持续时间
|
|
24
|
+
* @property {Object} styles 组件样式,同 css 样式,注意带’-‘连接符的属性需要使用小驼峰写法如:`backgroundColor:red`
|
|
25
|
+
*/
|
|
26
|
+
export default {
|
|
27
|
+
name: 'UniTransition',
|
|
28
|
+
emits: ['click', 'change'],
|
|
29
|
+
props: {
|
|
30
|
+
show: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false,
|
|
33
|
+
},
|
|
34
|
+
modeClass: {
|
|
35
|
+
type: [Array, String],
|
|
36
|
+
default() {
|
|
37
|
+
return 'fade';
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
duration: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 300,
|
|
43
|
+
},
|
|
44
|
+
styles: {
|
|
45
|
+
type: Object,
|
|
46
|
+
default() {
|
|
47
|
+
return {};
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
customClass: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: '',
|
|
53
|
+
},
|
|
54
|
+
onceRender: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: false,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
data() {
|
|
60
|
+
return {
|
|
61
|
+
isShow: false,
|
|
62
|
+
transform: '',
|
|
63
|
+
opacity: 1,
|
|
64
|
+
animationData: {},
|
|
65
|
+
durationTime: 300,
|
|
66
|
+
config: {},
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
watch: {
|
|
70
|
+
show: {
|
|
71
|
+
handler(newVal) {
|
|
72
|
+
if (newVal) {
|
|
73
|
+
this.open();
|
|
74
|
+
} else {
|
|
75
|
+
// 避免上来就执行 close,导致动画错乱
|
|
76
|
+
if (this.isShow) {
|
|
77
|
+
this.close();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
immediate: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
computed: {
|
|
85
|
+
// 生成样式数据
|
|
86
|
+
stylesObject() {
|
|
87
|
+
let styles = {
|
|
88
|
+
...this.styles,
|
|
89
|
+
'transition-duration': this.duration / 1000 + 's',
|
|
90
|
+
};
|
|
91
|
+
let transform = '';
|
|
92
|
+
for (let i in styles) {
|
|
93
|
+
let line = this.toLine(i);
|
|
94
|
+
transform += line + ':' + styles[i] + ';';
|
|
95
|
+
}
|
|
96
|
+
return transform;
|
|
97
|
+
},
|
|
98
|
+
// 初始化动画条件
|
|
99
|
+
transformStyles() {
|
|
100
|
+
return 'transform:' + this.transform + ';' + 'opacity:' + this.opacity + ';' + this.stylesObject;
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
created() {
|
|
104
|
+
// 动画默认配置
|
|
105
|
+
this.config = {
|
|
106
|
+
duration: this.duration,
|
|
107
|
+
timingFunction: 'ease',
|
|
108
|
+
transformOrigin: '50% 50%',
|
|
109
|
+
delay: 0,
|
|
110
|
+
};
|
|
111
|
+
this.durationTime = this.duration;
|
|
112
|
+
},
|
|
113
|
+
methods: {
|
|
114
|
+
/**
|
|
115
|
+
* ref 触发 初始化动画
|
|
116
|
+
*/
|
|
117
|
+
init(obj = {}) {
|
|
118
|
+
if (obj.duration) {
|
|
119
|
+
this.durationTime = obj.duration;
|
|
120
|
+
}
|
|
121
|
+
this.animation = createAnimation(Object.assign(this.config, obj), this);
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* 点击组件触发回调
|
|
125
|
+
*/
|
|
126
|
+
onClick() {
|
|
127
|
+
this.$emit('click', {
|
|
128
|
+
detail: this.isShow,
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* ref 触发 动画分组
|
|
133
|
+
* @param {Object} obj
|
|
134
|
+
*/
|
|
135
|
+
step(obj, config = {}) {
|
|
136
|
+
if (!this.animation) return;
|
|
137
|
+
for (let i in obj) {
|
|
138
|
+
try {
|
|
139
|
+
if (typeof obj[i] === 'object') {
|
|
140
|
+
this.animation[i](...obj[i]);
|
|
141
|
+
} else {
|
|
142
|
+
this.animation[i](obj[i]);
|
|
143
|
+
}
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.error(`方法 ${i} 不存在`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.animation.step(config);
|
|
149
|
+
return this;
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* ref 触发 执行动画
|
|
153
|
+
*/
|
|
154
|
+
run(fn) {
|
|
155
|
+
if (!this.animation) return;
|
|
156
|
+
this.animation.run(fn);
|
|
157
|
+
},
|
|
158
|
+
// 开始过度动画
|
|
159
|
+
open() {
|
|
160
|
+
clearTimeout(this.timer);
|
|
161
|
+
this.transform = '';
|
|
162
|
+
this.isShow = true;
|
|
163
|
+
let { opacity, transform } = this.styleInit(false);
|
|
164
|
+
if (typeof opacity !== 'undefined') {
|
|
165
|
+
this.opacity = opacity;
|
|
166
|
+
}
|
|
167
|
+
this.transform = transform;
|
|
168
|
+
// 确保动态样式已经生效后,执行动画,如果不加 nextTick ,会导致 wx 动画执行异常
|
|
169
|
+
this.$nextTick(() => {
|
|
170
|
+
// TODO 定时器保证动画完全执行,目前有些问题,后面会取消定时器
|
|
171
|
+
this.timer = setTimeout(() => {
|
|
172
|
+
this.animation = createAnimation(this.config, this);
|
|
173
|
+
this.tranfromInit(false).step();
|
|
174
|
+
this.animation.run();
|
|
175
|
+
this.$emit('change', {
|
|
176
|
+
detail: this.isShow,
|
|
177
|
+
});
|
|
178
|
+
}, 20);
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
// 关闭过度动画
|
|
182
|
+
close(type) {
|
|
183
|
+
if (!this.animation) return;
|
|
184
|
+
this.tranfromInit(true)
|
|
185
|
+
.step()
|
|
186
|
+
.run(() => {
|
|
187
|
+
this.isShow = false;
|
|
188
|
+
this.animationData = null;
|
|
189
|
+
this.animation = null;
|
|
190
|
+
let { opacity, transform } = this.styleInit(false);
|
|
191
|
+
this.opacity = opacity || 1;
|
|
192
|
+
this.transform = transform;
|
|
193
|
+
this.$emit('change', {
|
|
194
|
+
detail: this.isShow,
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
// 处理动画开始前的默认样式
|
|
199
|
+
styleInit(type) {
|
|
200
|
+
let styles = {
|
|
201
|
+
transform: '',
|
|
202
|
+
};
|
|
203
|
+
let buildStyle = (type, mode) => {
|
|
204
|
+
if (mode === 'fade') {
|
|
205
|
+
styles.opacity = this.animationType(type)[mode];
|
|
206
|
+
} else {
|
|
207
|
+
styles.transform += this.animationType(type)[mode] + ' ';
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
if (typeof this.modeClass === 'string') {
|
|
211
|
+
buildStyle(type, this.modeClass);
|
|
212
|
+
} else {
|
|
213
|
+
this.modeClass.forEach((mode) => {
|
|
214
|
+
buildStyle(type, mode);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return styles;
|
|
218
|
+
},
|
|
219
|
+
// 处理内置组合动画
|
|
220
|
+
tranfromInit(type) {
|
|
221
|
+
let buildTranfrom = (type, mode) => {
|
|
222
|
+
let aniNum = null;
|
|
223
|
+
if (mode === 'fade') {
|
|
224
|
+
aniNum = type ? 0 : 1;
|
|
225
|
+
} else {
|
|
226
|
+
aniNum = type ? '-100%' : '0';
|
|
227
|
+
if (mode === 'zoom-in') {
|
|
228
|
+
aniNum = type ? 0.8 : 1;
|
|
229
|
+
}
|
|
230
|
+
if (mode === 'zoom-out') {
|
|
231
|
+
aniNum = type ? 1.2 : 1;
|
|
232
|
+
}
|
|
233
|
+
if (mode === 'slide-right') {
|
|
234
|
+
aniNum = type ? '100%' : '0';
|
|
235
|
+
}
|
|
236
|
+
if (mode === 'slide-bottom') {
|
|
237
|
+
aniNum = type ? '100%' : '0';
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
this.animation[this.animationMode()[mode]](aniNum);
|
|
241
|
+
};
|
|
242
|
+
if (typeof this.modeClass === 'string') {
|
|
243
|
+
buildTranfrom(type, this.modeClass);
|
|
244
|
+
} else {
|
|
245
|
+
this.modeClass.forEach((mode) => {
|
|
246
|
+
buildTranfrom(type, mode);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
247
249
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
250
|
+
return this.animation;
|
|
251
|
+
},
|
|
252
|
+
animationType(type) {
|
|
253
|
+
return {
|
|
254
|
+
fade: type ? 1 : 0,
|
|
255
|
+
'slide-top': `translateY(${type ? '0' : '-100%'})`,
|
|
256
|
+
'slide-right': `translateX(${type ? '0' : '100%'})`,
|
|
257
|
+
'slide-bottom': `translateY(${type ? '0' : '100%'})`,
|
|
258
|
+
'slide-left': `translateX(${type ? '0' : '-100%'})`,
|
|
259
|
+
'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`,
|
|
260
|
+
'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})`,
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
// 内置动画类型与实际动画对应字典
|
|
264
|
+
animationMode() {
|
|
265
|
+
return {
|
|
266
|
+
fade: 'opacity',
|
|
267
|
+
'slide-top': 'translateY',
|
|
268
|
+
'slide-right': 'translateX',
|
|
269
|
+
'slide-bottom': 'translateY',
|
|
270
|
+
'slide-left': 'translateX',
|
|
271
|
+
'zoom-in': 'scale',
|
|
272
|
+
'zoom-out': 'scale',
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
// 驼峰转中横线
|
|
276
|
+
toLine(name) {
|
|
277
|
+
return name.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
};
|
|
279
281
|
</script>
|
|
280
282
|
|
|
281
283
|
<style></style>
|