hy-app 0.4.13 → 0.5.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/components/hy-action-sheet/hy-action-sheet.vue +155 -238
- package/components/hy-action-sheet/props.ts +68 -15
- package/components/hy-action-sheet/typing.d.ts +115 -115
- package/components/hy-address-picker/hy-address-picker.vue +185 -289
- package/components/hy-address-picker/props.ts +97 -21
- package/components/hy-address-picker/typing.d.ts +90 -89
- package/components/hy-avatar/hy-avatar.vue +121 -204
- package/components/hy-avatar/props.ts +76 -18
- package/components/hy-avatar/typing.d.ts +63 -62
- package/components/hy-back-top/hy-back-top.vue +65 -120
- package/components/hy-back-top/props.ts +57 -16
- package/components/hy-back-top/typing.d.ts +43 -42
- package/components/hy-badge/hy-badge.vue +66 -138
- package/components/hy-badge/props.ts +73 -17
- package/components/hy-badge/typing.d.ts +59 -58
- package/components/hy-button/hy-button.vue +226 -375
- package/components/hy-button/props.ts +129 -158
- package/components/hy-calendar/header.vue +48 -64
- package/components/hy-calendar/hy-calendar.vue +274 -438
- package/components/hy-calendar/month.vue +508 -516
- package/components/hy-calendar/props.ts +157 -35
- package/components/hy-calendar/typing.d.ts +129 -128
- package/components/hy-card/hy-card.vue +118 -240
- package/components/hy-card/index.scss +1 -2
- package/components/hy-card/props.ts +122 -27
- package/components/hy-card/typing.d.ts +119 -118
- package/components/hy-cell/hy-cell.vue +176 -258
- package/components/hy-cell/props.ts +71 -17
- package/components/hy-cell/typing.d.ts +87 -86
- package/components/hy-check-button/hy-check-button.vue +69 -139
- package/components/hy-check-button/props.ts +72 -18
- package/components/hy-check-button/typing.d.ts +74 -73
- package/components/hy-checkbox/hy-checkbox.vue +170 -263
- package/components/hy-checkbox/props.ts +94 -24
- package/components/hy-checkbox/typing.d.ts +72 -72
- package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
- package/components/hy-checkbox-group/props.ts +80 -0
- package/components/hy-checkbox-group/typing.d.ts +65 -65
- package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
- package/components/hy-checkbox-item/props.ts +24 -0
- package/components/hy-checkbox-item/typing.d.ts +4 -3
- package/components/hy-code-input/hy-code-input.vue +179 -262
- package/components/hy-code-input/props.ts +84 -18
- package/components/hy-code-input/typing.d.ts +71 -71
- package/components/hy-config-provider/hy-config-provider.vue +28 -50
- package/components/hy-config-provider/props.ts +26 -11
- package/components/hy-config-provider/typing.d.ts +20 -20
- package/components/hy-count-down/hy-count-down.vue +103 -131
- package/components/hy-count-down/props.ts +30 -8
- package/components/hy-count-down/typing.d.ts +25 -25
- package/components/hy-count-to/hy-count-to.vue +148 -213
- package/components/hy-count-to/props.ts +60 -15
- package/components/hy-count-to/typing.d.ts +46 -46
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +180 -0
- package/components/hy-coupon/index.scss +553 -0
- package/components/hy-coupon/props.ts +129 -0
- package/components/hy-coupon/typing.d.ts +146 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
- package/components/hy-datetime-picker/props.ts +142 -32
- package/components/hy-datetime-picker/typing.d.ts +132 -132
- package/components/hy-divider/hy-divider.vue +90 -169
- package/components/hy-divider/props.ts +78 -19
- package/components/hy-divider/typing.d.ts +60 -60
- package/components/hy-dropdown/hy-dropdown.vue +37 -71
- package/components/hy-dropdown/props.ts +38 -15
- package/components/hy-dropdown/typing.d.ts +44 -44
- package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
- package/components/hy-dropdown-item/props.ts +19 -8
- package/components/hy-empty/hy-empty.vue +75 -129
- package/components/hy-empty/props.ts +57 -15
- package/components/hy-empty/typing.d.ts +84 -84
- package/components/hy-flex/hy-flex.vue +33 -88
- package/components/hy-flex/props.ts +58 -0
- package/components/hy-flex/typing.d.ts +14 -16
- package/components/hy-float-button/hy-float-button.vue +289 -406
- package/components/hy-float-button/props.ts +109 -25
- package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
- package/components/hy-folding-panel/props.ts +40 -15
- package/components/hy-folding-panel/typing.d.ts +52 -63
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/props.ts +81 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-form/hy-form.vue +172 -212
- package/components/hy-form/props.ts +37 -0
- package/components/hy-form/typing.d.ts +68 -61
- package/components/hy-form-group/typing.d.ts +74 -74
- package/components/hy-form-item/hy-form-item.vue +100 -129
- package/components/hy-form-item/props.ts +25 -0
- package/components/hy-form-item/typing.d.ts +40 -37
- package/components/hy-grid/hy-grid.vue +76 -132
- package/components/hy-grid/props.ts +58 -16
- package/components/hy-grid/typing.d.ts +66 -66
- package/components/hy-icon/hy-icon.vue +84 -161
- package/components/hy-icon/props.ts +76 -22
- package/components/hy-icon/typing.d.ts +83 -82
- package/components/hy-image/hy-image.vue +142 -272
- package/components/hy-image/props.ts +105 -23
- package/components/hy-image/typing.d.ts +84 -87
- package/components/hy-input/hy-input.vue +230 -421
- package/components/hy-input/props.ts +183 -35
- package/components/hy-input/typing.d.ts +169 -169
- package/components/hy-line/hy-line.vue +34 -72
- package/components/hy-line/props.ts +41 -10
- package/components/hy-line/typing.d.ts +29 -29
- package/components/hy-line-progress/hy-line-progress.vue +66 -101
- package/components/hy-line-progress/props.ts +31 -10
- package/components/hy-line-progress/typing.d.ts +29 -29
- package/components/hy-list/hy-list.vue +151 -220
- package/components/hy-list/props.ts +67 -16
- package/components/hy-list/typing.d.ts +52 -52
- package/components/hy-loading/hy-loading.vue +63 -119
- package/components/hy-loading/props.ts +63 -15
- package/components/hy-loading/typing.d.ts +49 -49
- package/components/hy-menu/hy-menu.vue +124 -166
- package/components/hy-menu/props.ts +42 -10
- package/components/hy-menu/typing.d.ts +60 -60
- package/components/hy-modal/hy-modal.vue +127 -218
- package/components/hy-modal/props.ts +89 -24
- package/components/hy-navbar/hy-navbar.vue +104 -177
- package/components/hy-navbar/props.ts +76 -22
- package/components/hy-navbar/typing.d.ts +81 -81
- package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
- package/components/hy-notice-bar/props.ts +80 -19
- package/components/hy-notice-bar/typing.d.ts +62 -62
- package/components/hy-notify/hy-notify.vue +128 -177
- package/components/hy-notify/props.ts +49 -12
- package/components/hy-notify/typing.d.ts +45 -41
- package/components/hy-number-step/hy-number-step.vue +281 -394
- package/components/hy-number-step/props.ts +110 -27
- package/components/hy-number-step/typing.d.ts +120 -120
- package/components/hy-overlay/hy-overlay.vue +39 -66
- package/components/hy-overlay/props.ts +31 -8
- package/components/hy-pagination/hy-pagination.vue +100 -155
- package/components/hy-pagination/props.ts +53 -13
- package/components/hy-picker/hy-picker.vue +309 -430
- package/components/hy-picker/index.scss +8 -12
- package/components/hy-picker/props.ts +110 -26
- package/components/hy-popover/hy-popover.vue +190 -252
- package/components/hy-popover/props.ts +48 -10
- package/components/hy-popup/hy-popup.vue +162 -248
- package/components/hy-popup/props.ts +82 -18
- package/components/hy-price/hy-price.vue +45 -104
- package/components/hy-price/props.ts +52 -12
- package/components/hy-price/typing.d.ts +41 -36
- package/components/hy-qrcode/hy-qrcode.vue +115 -185
- package/components/hy-qrcode/props.ts +68 -18
- package/components/hy-qrcode/typing.d.ts +67 -66
- package/components/hy-radio/hy-radio.vue +161 -259
- package/components/hy-radio/props.ts +95 -25
- package/components/hy-radio/typing.d.ts +85 -84
- package/components/hy-rate/hy-rate.vue +185 -270
- package/components/hy-rate/props.ts +76 -18
- package/components/hy-rate/typing.d.ts +61 -60
- package/components/hy-read-more/hy-read-more.vue +93 -136
- package/components/hy-read-more/props.ts +43 -13
- package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
- package/components/hy-scroll-list/props.ts +22 -11
- package/components/hy-search/hy-search.vue +155 -284
- package/components/hy-search/props.ts +130 -25
- package/components/hy-signature/hy-signature.vue +491 -635
- package/components/hy-signature/props.ts +115 -26
- package/components/hy-signature/typing.d.ts +138 -138
- package/components/hy-slider/hy-slider.vue +388 -477
- package/components/hy-slider/props.ts +75 -19
- package/components/hy-steps/hy-steps.vue +212 -279
- package/components/hy-steps/props.ts +47 -13
- package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
- package/components/hy-submit-bar/props.ts +89 -20
- package/components/hy-submit-bar/typing.d.ts +86 -85
- package/components/hy-subsection/hy-subsection.vue +132 -185
- package/components/hy-subsection/props.ts +50 -17
- package/components/hy-subsection/typing.d.ts +52 -52
- package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
- package/components/hy-swipe-action/props.ts +43 -18
- package/components/hy-swipe-action/typing.d.ts +46 -46
- package/components/hy-swiper/hy-swiper.vue +159 -286
- package/components/hy-swiper/props.ts +126 -28
- package/components/hy-swiper/typing.d.ts +115 -115
- package/components/hy-switch/hy-switch.vue +112 -176
- package/components/hy-switch/props.ts +60 -15
- package/components/hy-switch/typing.d.ts +63 -63
- package/components/hy-tabBar/hy-tabBar.vue +64 -60
- package/components/hy-tabs/hy-tabs.vue +277 -380
- package/components/hy-tabs/props.ts +75 -18
- package/components/hy-tag/hy-tag.vue +111 -204
- package/components/hy-tag/props.ts +81 -19
- package/components/hy-text/hy-text.vue +200 -322
- package/components/hy-text/props.ts +107 -28
- package/components/hy-textarea/hy-textarea.vue +147 -256
- package/components/hy-textarea/props.ts +112 -25
- package/components/hy-textarea/typing.d.ts +42 -42
- package/components/hy-toast/hy-toast.vue +135 -143
- package/components/hy-tooltip/hy-tooltip.vue +220 -306
- package/components/hy-tooltip/props.ts +79 -15
- package/components/hy-transition/hy-transition.vue +111 -138
- package/components/hy-transition/props.ts +30 -8
- package/components/hy-upload/hy-upload.vue +320 -469
- package/components/hy-upload/props.ts +130 -27
- package/components/hy-warn/hy-warn.vue +80 -129
- package/components/hy-warn/props.ts +47 -12
- package/components/hy-waterfall/hy-waterfall.vue +139 -163
- package/components/hy-waterfall/props.ts +19 -7
- package/components/hy-watermark/hy-watermark.vue +762 -870
- package/components/hy-watermark/props.ts +103 -22
- package/global.d.ts +2 -0
- package/libs/css/theme.scss +3 -3
- package/package.json +2 -2
- package/web-types.json +1 -1
- package/components/hy-folding-panel/index.scss +0 -9
|
@@ -1,17 +1,81 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
+
import type { IPlacementVo } from '@/package/components/hy-popover/typing'
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
const tooltipProps = {
|
|
5
|
+
/** 需要显示的提示文字 */
|
|
6
|
+
text: {
|
|
7
|
+
type: String,
|
|
8
|
+
default: ''
|
|
9
|
+
},
|
|
10
|
+
/** 点击复制按钮时,复制的文本,为空则使用text值 */
|
|
11
|
+
copyText: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: ''
|
|
14
|
+
},
|
|
15
|
+
/**
|
|
16
|
+
* 触发模式
|
|
17
|
+
* @values longpress,click
|
|
18
|
+
* */
|
|
19
|
+
triggerMode: {
|
|
20
|
+
type: String as PropType<'longpress' | 'click'>,
|
|
21
|
+
default: 'longpress'
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* 指定 popover 的放置位置
|
|
25
|
+
* @values top,top-start,top-end,bottom,bottom-start,bottom-end,left,left-start,left-end,right,right-start,right-end
|
|
26
|
+
* */
|
|
27
|
+
placement: {
|
|
28
|
+
type: String as PropType<IPlacementVo>,
|
|
29
|
+
default: 'bottom'
|
|
30
|
+
},
|
|
31
|
+
/** 文本大小 */
|
|
32
|
+
size: {
|
|
33
|
+
type: [String, Number],
|
|
34
|
+
default: 14
|
|
35
|
+
},
|
|
36
|
+
/** 字体颜色 */
|
|
37
|
+
color: String,
|
|
38
|
+
/** 字体粗细 */
|
|
39
|
+
bold: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false
|
|
42
|
+
},
|
|
43
|
+
/** 弹出提示框时,文本的背景色 */
|
|
44
|
+
bgColor: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: 'transparent'
|
|
47
|
+
},
|
|
48
|
+
/** 弹出提示的z-index,nvue无效 */
|
|
49
|
+
zIndex: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 10071
|
|
52
|
+
},
|
|
53
|
+
/** 是否显示复制按钮 */
|
|
54
|
+
showCopy: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: true
|
|
57
|
+
},
|
|
58
|
+
/** 扩展的按钮组 */
|
|
59
|
+
buttons: {
|
|
60
|
+
type: Array,
|
|
61
|
+
default() {
|
|
62
|
+
return []
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
/** 是否显示透明遮罩以防止触摸穿透 */
|
|
66
|
+
overlay: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: true
|
|
69
|
+
},
|
|
70
|
+
/** 是否显示提示 */
|
|
71
|
+
showToast: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: true
|
|
74
|
+
},
|
|
75
|
+
/** 定义需要用到的外部样式 */
|
|
76
|
+
customStyle: Object as PropType<CSSProperties>,
|
|
77
|
+
/** 自定义外部类名 */
|
|
78
|
+
customClass: String
|
|
79
|
+
}
|
|
16
80
|
|
|
17
|
-
export default
|
|
81
|
+
export default tooltipProps
|
|
@@ -1,184 +1,157 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
<view
|
|
3
|
+
v-if="hasInit"
|
|
4
|
+
class="hy-transition"
|
|
5
|
+
ref="u-transition"
|
|
6
|
+
@tap.stop="clickHandler"
|
|
7
|
+
:class="[classes, customClass]"
|
|
8
|
+
:style="[mergeStyle]"
|
|
9
|
+
>
|
|
10
|
+
<slot />
|
|
11
|
+
</view>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
14
|
<script lang="ts">
|
|
15
15
|
export default {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
16
|
+
name: 'hy-transition',
|
|
17
|
+
options: {
|
|
18
|
+
addGlobalClass: true,
|
|
19
|
+
virtualHost: true,
|
|
20
|
+
styleIsolation: 'shared'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
23
|
</script>
|
|
24
24
|
|
|
25
25
|
<script setup lang="ts">
|
|
26
|
-
import { computed, ref, watch, nextTick } from
|
|
27
|
-
import type { CSSProperties
|
|
28
|
-
import { sleep } from
|
|
29
|
-
import type { ITransitionEmits } from
|
|
26
|
+
import { computed, ref, watch, nextTick } from 'vue'
|
|
27
|
+
import type { CSSProperties } from 'vue'
|
|
28
|
+
import { sleep } from '../../libs'
|
|
29
|
+
import type { ITransitionEmits } from './typing'
|
|
30
|
+
import transitionProps from './props'
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* 该组件用于组件的动画过渡效果。
|
|
33
34
|
* @displayName hy-transition
|
|
34
35
|
*/
|
|
35
|
-
defineOptions({})
|
|
36
|
+
defineOptions({})
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
/** 是否展示组件 */
|
|
40
|
-
show: {
|
|
41
|
-
type: Boolean,
|
|
42
|
-
default: false,
|
|
43
|
-
},
|
|
44
|
-
/** 使用的动画模式 */
|
|
45
|
-
mode: {
|
|
46
|
-
type: String,
|
|
47
|
-
default: "fade",
|
|
48
|
-
},
|
|
49
|
-
/** 动画的执行时间,单位ms */
|
|
50
|
-
duration: {
|
|
51
|
-
type: Number,
|
|
52
|
-
default: 300,
|
|
53
|
-
},
|
|
54
|
-
/** 使用的动画过渡函数 */
|
|
55
|
-
timingFunction: {
|
|
56
|
-
type: String,
|
|
57
|
-
default: "ease-out",
|
|
58
|
-
},
|
|
59
|
-
/** 定义需要用到的外部样式 */
|
|
60
|
-
customStyle: {
|
|
61
|
-
type: Object as PropType<CSSProperties>,
|
|
62
|
-
},
|
|
63
|
-
/** 自定义外部类名 */
|
|
64
|
-
customClass: String,
|
|
65
|
-
});
|
|
66
|
-
const emit = defineEmits<ITransitionEmits>();
|
|
38
|
+
const props = defineProps(transitionProps)
|
|
39
|
+
const emit = defineEmits<ITransitionEmits>()
|
|
67
40
|
|
|
68
|
-
const hasInit = ref<boolean>(false)
|
|
69
|
-
const viewStyle = ref<CSSProperties>({})
|
|
70
|
-
const status = ref<string>(
|
|
71
|
-
const transitionEnded = ref<boolean>(false)
|
|
72
|
-
const display = ref<boolean>(false)
|
|
73
|
-
const classes = ref<string>(
|
|
41
|
+
const hasInit = ref<boolean>(false) // 是否显示/隐藏组件
|
|
42
|
+
const viewStyle = ref<CSSProperties>({}) // 组件内部的样式
|
|
43
|
+
const status = ref<string>('') // 记录组件动画的状态
|
|
44
|
+
const transitionEnded = ref<boolean>(false) // 组件是否结束的标记
|
|
45
|
+
const display = ref<boolean>(false) // 组件是否展示
|
|
46
|
+
const classes = ref<string>('') // 应用的类名
|
|
74
47
|
|
|
75
48
|
// #ifndef APP-NVUE
|
|
76
49
|
// 定义类名,通过给元素动态切换类名,赋予元素一定的css动画样式
|
|
77
50
|
const getClassNames = (name: string) => ({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
51
|
+
enter: `u-${name}-enter u-${name}-enter-active`,
|
|
52
|
+
'enter-to': `u-${name}-enter-to u-${name}-enter-active`,
|
|
53
|
+
leave: `u-${name}-leave u-${name}-leave-active`,
|
|
54
|
+
'leave-to': `u-${name}-leave-to u-${name}-leave-active`
|
|
55
|
+
})
|
|
83
56
|
// #endif
|
|
84
57
|
|
|
85
58
|
// #ifndef APP-NVUE
|
|
86
59
|
// vue版本的组件进场处理
|
|
87
60
|
const vueEnter = async () => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
61
|
+
// 动画进入时的类名
|
|
62
|
+
const classNames = getClassNames(props.mode)
|
|
63
|
+
// 定义状态和发出动画进入前事件
|
|
64
|
+
status.value = 'enter'
|
|
65
|
+
emit('beforeEnter')
|
|
66
|
+
hasInit.value = true
|
|
67
|
+
display.value = true
|
|
68
|
+
classes.value = classNames.enter
|
|
69
|
+
await nextTick()
|
|
70
|
+
{
|
|
71
|
+
// https://github.com/umicro/uView2.0/issues/545
|
|
72
|
+
await sleep(20)
|
|
73
|
+
// 标识动画尚未结束
|
|
74
|
+
emit('enter')
|
|
75
|
+
transitionEnded.value = false
|
|
76
|
+
// 组件动画进入后触发的事件
|
|
77
|
+
emit('afterEnter')
|
|
78
|
+
// 赋予组件enter-to类名
|
|
79
|
+
classes.value = classNames['enter-to']
|
|
80
|
+
}
|
|
81
|
+
}
|
|
109
82
|
// 动画离场处理
|
|
110
83
|
const vueLeave = async () => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
84
|
+
// 如果不是展示状态,无需执行逻辑
|
|
85
|
+
if (!display.value) return
|
|
86
|
+
const classNames = getClassNames(props.mode)
|
|
87
|
+
// 标记离开状态和发出事件
|
|
88
|
+
status.value = 'leave'
|
|
89
|
+
emit('beforeLeave')
|
|
90
|
+
// 获得类名
|
|
91
|
+
classes.value = classNames.leave
|
|
119
92
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
93
|
+
await nextTick()
|
|
94
|
+
{
|
|
95
|
+
// 动画正在离场的状态
|
|
96
|
+
transitionEnded.value = false
|
|
97
|
+
emit('leave')
|
|
98
|
+
// 组件执行动画,到了执行的执行时间后,执行一些额外处理
|
|
99
|
+
setTimeout(() => onTransitionEnd(), props.duration)
|
|
100
|
+
classes.value = classNames['leave-to']
|
|
101
|
+
}
|
|
102
|
+
}
|
|
130
103
|
// #endif
|
|
131
104
|
|
|
132
105
|
watch(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
)
|
|
106
|
+
() => props.show,
|
|
107
|
+
(newVal) => {
|
|
108
|
+
// vue和nvue分别执行不同的方法
|
|
109
|
+
// #ifdef APP-NVUE
|
|
110
|
+
// newVal ? nvueEnter() : nvueLeave()
|
|
111
|
+
// #endif
|
|
112
|
+
// #ifndef APP-NVUE
|
|
113
|
+
newVal ? vueEnter() : vueLeave()
|
|
114
|
+
// #endif
|
|
115
|
+
},
|
|
116
|
+
{ immediate: true }
|
|
117
|
+
)
|
|
145
118
|
|
|
146
119
|
const mergeStyle = computed(() => {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
})
|
|
120
|
+
return {
|
|
121
|
+
// #ifndef APP-NVUE
|
|
122
|
+
transitionDuration: `${props.duration}ms`,
|
|
123
|
+
// display: `${this.display ? '' : 'none'}`,
|
|
124
|
+
transitionTimingFunction: props.timingFunction,
|
|
125
|
+
// #endif
|
|
126
|
+
// 避免自定义样式影响到动画属性,所以写在viewStyle前面
|
|
127
|
+
...props.customStyle,
|
|
128
|
+
...viewStyle
|
|
129
|
+
}
|
|
130
|
+
})
|
|
158
131
|
|
|
159
132
|
/**
|
|
160
133
|
* @description 组件被点击发出事件
|
|
161
134
|
* */
|
|
162
135
|
const clickHandler = () => {
|
|
163
|
-
|
|
164
|
-
}
|
|
136
|
+
emit('click')
|
|
137
|
+
}
|
|
165
138
|
|
|
166
139
|
const onTransitionEnd = () => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
140
|
+
// 如果已经是结束的状态,无需再处理
|
|
141
|
+
if (transitionEnded.value) return
|
|
142
|
+
transitionEnded.value = true
|
|
143
|
+
// 发出组件动画执行后的事件
|
|
144
|
+
status.value === 'leave' ? emit('afterLeave') : emit('afterEnter')
|
|
145
|
+
if (!props.show && display.value) {
|
|
146
|
+
display.value = false
|
|
147
|
+
hasInit.value = false
|
|
148
|
+
}
|
|
149
|
+
}
|
|
177
150
|
</script>
|
|
178
151
|
|
|
179
152
|
<style lang="scss" scoped>
|
|
180
153
|
/* #ifndef APP-NVUE */
|
|
181
154
|
// vue版本动画相关的样式抽离在外部文件
|
|
182
|
-
@import
|
|
155
|
+
@import './index.scss';
|
|
183
156
|
/* #endif */
|
|
184
157
|
</style>
|
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
3
|
+
const transitionProps = {
|
|
4
|
+
/** 是否展示组件 */
|
|
5
|
+
show: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false
|
|
8
|
+
},
|
|
9
|
+
/** 使用的动画模式 */
|
|
10
|
+
mode: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: 'fade'
|
|
13
|
+
},
|
|
14
|
+
/** 动画的执行时间,单位ms */
|
|
15
|
+
duration: {
|
|
16
|
+
type: Number,
|
|
17
|
+
default: 300
|
|
18
|
+
},
|
|
19
|
+
/** 使用的动画过渡函数 */
|
|
20
|
+
timingFunction: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: 'ease-out'
|
|
23
|
+
},
|
|
24
|
+
/** 定义需要用到的外部样式 */
|
|
25
|
+
customStyle: {
|
|
26
|
+
type: Object as PropType<CSSProperties>
|
|
27
|
+
},
|
|
28
|
+
/** 自定义外部类名 */
|
|
29
|
+
customClass: String
|
|
30
|
+
}
|
|
9
31
|
|
|
10
|
-
export default
|
|
32
|
+
export default transitionProps
|