mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* perf: change to import-x * feat: add rules * chore: fix rule * chore: fix * chore: fix * chore: fix * style: `pnpm lint:fix` * Revert "style: `pnpm lint:fix`" This reverts commitdb0116a288. * Revert "chore: fix" This reverts commit69c82a90c0. * chore: fix * style: `pnpm lint:fix` * fix: lint * chore: `pnpm format`
56 lines
1.5 KiB
Vue
56 lines
1.5 KiB
Vue
<template>
|
|
<transition mode="out-in" v-bind="listeners">
|
|
<slot />
|
|
</transition>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { useNamespace } from '@element-plus/hooks'
|
|
import { addClass, hasClass, removeClass } from '@element-plus/utils'
|
|
|
|
import type { BaseTransitionProps, TransitionProps } from 'vue'
|
|
|
|
defineOptions({
|
|
name: 'ElMenuCollapseTransition',
|
|
})
|
|
|
|
const ns = useNamespace('menu')
|
|
const listeners = {
|
|
onBeforeEnter: (el) => (el.style.opacity = '0.2'),
|
|
onEnter(el, done) {
|
|
addClass(el, `${ns.namespace.value}-opacity-transition`)
|
|
el.style.opacity = '1'
|
|
done()
|
|
},
|
|
|
|
onAfterEnter(el) {
|
|
removeClass(el, `${ns.namespace.value}-opacity-transition`)
|
|
el.style.opacity = ''
|
|
},
|
|
|
|
onBeforeLeave(el) {
|
|
if (!el.dataset) (el as any).dataset = {}
|
|
|
|
if (hasClass(el, ns.m('collapse'))) {
|
|
removeClass(el, ns.m('collapse'))
|
|
el.dataset.oldOverflow = el.style.overflow
|
|
el.dataset.scrollWidth = el.clientWidth.toString()
|
|
addClass(el, ns.m('collapse'))
|
|
} else {
|
|
addClass(el, ns.m('collapse'))
|
|
el.dataset.oldOverflow = el.style.overflow
|
|
el.dataset.scrollWidth = el.clientWidth.toString()
|
|
removeClass(el, ns.m('collapse'))
|
|
}
|
|
|
|
el.style.width = `${el.scrollWidth}px`
|
|
el.style.overflow = 'hidden'
|
|
},
|
|
|
|
onLeave(el: HTMLElement) {
|
|
addClass(el, 'horizontal-collapse-transition')
|
|
el.style.width = `${el.dataset.scrollWidth}px`
|
|
},
|
|
} as BaseTransitionProps<HTMLElement> as TransitionProps
|
|
</script>
|