-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
190 additions
and
152 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
67 changes: 45 additions & 22 deletions
67
frontend/src/components/transitions/FadeAndSlideTransitionGroup.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,70 @@ | ||
<script lang="ts" setup> | ||
import { TransitionGroup } from 'vue'; | ||
defineOptions({ | ||
name: 'FadeAndSlideTransitionGroup', | ||
name: 'FadeAndSlideTransitionGroup', | ||
}); | ||
const transitionRef = ref<any | null>(null); | ||
const onEnter = (el: Element, done: () => void) => { | ||
const transitionContainer = transitionRef.value!.$el as HTMLElement; | ||
console.log('onEnter', el, transitionContainer); | ||
let prevHeight = el.clientHeight; | ||
transitionContainer.style.height = `${prevHeight}px`; | ||
setTimeout(() => { | ||
transitionContainer.style.height = ''; | ||
}, 300); | ||
console.log('onEnter'); | ||
const transitionContainer = transitionRef.value!.$el as HTMLElement; | ||
const transitionEl = el as HTMLElement; | ||
let prevHeight = el.clientHeight; | ||
transitionContainer.style.height = `${prevHeight}px`; | ||
transitionEl.style.visibility = 'hidden'; | ||
let timer = setInterval(() => { | ||
const height = el.clientHeight; | ||
if (height !== prevHeight) { | ||
transitionContainer.style.height = `${height}px`; | ||
prevHeight = height; | ||
} | ||
}, 100); | ||
setTimeout(() => { | ||
// 与onLeave的duration保持一致 | ||
transitionEl.style.visibility = ''; | ||
transitionContainer.style.opacity = '1'; | ||
}, 150); | ||
setTimeout(() => { | ||
clearInterval(timer); | ||
transitionContainer.style.height = ''; | ||
transitionContainer.style.opacity = ''; | ||
done(); | ||
}, 400); | ||
}; | ||
const onLeave = (el: Element, done: () => void) => { | ||
const transitionContainer = transitionRef.value!.$el as HTMLElement; | ||
const height = el.clientHeight; | ||
transitionContainer.style.height = `${height}px`; | ||
console.log('onLeave'); | ||
const transitionContainer = transitionRef.value!.$el as HTMLElement; | ||
const height = el.clientHeight; | ||
transitionContainer.style.height = `${height}px`; | ||
transitionContainer.style.opacity = '0'; | ||
setTimeout(() => { | ||
console.log('onLeave done'); | ||
done(); | ||
}, 150); | ||
}; | ||
const onAfterEnter = () => { | ||
// const transitionContainer = transitionRef.value!.$el as HTMLElement; | ||
// transitionContainer.style.height = ''; | ||
// const transitionContainer = transitionRef.value!.$el as HTMLElement; | ||
// transitionContainer.style.height = ''; | ||
}; | ||
</script> | ||
|
||
<template> | ||
<TransitionGroup name="fade-and-slide" tag="div" class="fade-and-slide" ref="transitionRef" | ||
@enter="onEnter" @leave="onLeave" @after-enter="onAfterEnter"> | ||
<slot></slot> | ||
</TransitionGroup> | ||
<TransitionGroup name="fade-and-slide" tag="div" class="fade-and-slide" ref="transitionRef" @enter="onEnter" | ||
@leave="onLeave" @after-enter="onAfterEnter" mode="out-in"> | ||
<slot></slot> | ||
</TransitionGroup> | ||
</template> | ||
|
||
<style scoped> | ||
.fade-and-slide { | ||
transition: height 250ms ease-in-out; | ||
overflow: hidden; | ||
transition: height 250ms ease-in-out, opacity 100ms linear; | ||
opacity: 1; | ||
overflow: hidden; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.