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