mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-27 03:01:14 +08:00
425567ec3b
* refactor(hooks): refactor transition - Introduce new hook named useTransition - Update transition.scss with css vars * - Align variable name. * - Update transitions to cssvars * - Address PR comments
36 lines
810 B
TypeScript
36 lines
810 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`,
|
|
),
|
|
}
|
|
}
|