mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 18:01:24 +08:00
55348b30b6
* style: use prettier * style: just prettier format, no code changes * style: eslint fix object-shorthand, prefer-const * style: fix no-void * style: no-console
34 lines
793 B
TypeScript
34 lines
793 B
TypeScript
import { computed, ref, watch, nextTick } from 'vue'
|
|
|
|
import type { ExtractPropTypes, Ref } from 'vue'
|
|
|
|
export const useTransitionProps = {
|
|
transitionDuration: {
|
|
type: Number,
|
|
default: 0.3,
|
|
},
|
|
transitionShow: String,
|
|
transitionHide: String,
|
|
}
|
|
|
|
export const useTransition = (
|
|
props: ExtractPropTypes<typeof useTransitionProps>,
|
|
indicator: Ref<boolean>
|
|
) => {
|
|
const transitionState = ref(indicator.value)
|
|
watch(indicator, (val) => {
|
|
nextTick(() => (transitionState.value = val))
|
|
})
|
|
|
|
return {
|
|
transition: computed(() => {
|
|
return `el-transition--${
|
|
transitionState.value ? props.transitionShow : props.transitionHide
|
|
}`
|
|
}),
|
|
transitionStyle: computed(
|
|
() => `--el-transition-duration: ${props.transitionDuration}s`
|
|
),
|
|
}
|
|
}
|