-
Notifications
You must be signed in to change notification settings - Fork 34
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
24 changed files
with
838 additions
and
581 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
packages/toolkits/pro/template/tinyvue/src/components/index.ts
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,8 +1,16 @@ | ||
import { App } from 'vue'; | ||
import Breadcrumb from './breadcrumb/index.vue'; | ||
import TransitionFadeDownGroup from './transition/transition-fade-down-group.vue'; | ||
import TransitionFadeDown from './transition/transition-fade-down.vue'; | ||
import TransitionFadeSlideGroup from './transition/transition-fade-slide-group.vue'; | ||
import TransitionFadeSlide from './transition/transition-fade-slide.vue'; | ||
|
||
export default { | ||
install(Vue: App) { | ||
Vue.component('Breadcrumb', Breadcrumb); | ||
Vue.component('TransitionFadeDownGroup', TransitionFadeDownGroup); | ||
Vue.component('TransitionFadeDown', TransitionFadeDown); | ||
Vue.component('TransitionSlideGroup', TransitionFadeSlideGroup); | ||
Vue.component('TransitionSlide', TransitionFadeSlide); | ||
}, | ||
}; |
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
51 changes: 51 additions & 0 deletions
51
...es/toolkits/pro/template/tinyvue/src/components/transition/transition-fade-down-group.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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script lang="ts" setup> | ||
import { findIdx } from './utils'; | ||
let count = 0; | ||
const onBeforeEnter = (el: HTMLElement) => { | ||
el.style.opacity = '0'; | ||
el.style.transform = 'translateY(-20px)'; | ||
el.style.transition = 'all 300ms ease-in-out'; | ||
count += 1; | ||
}; | ||
const onEnter = (el: HTMLElement, done: () => void) => { | ||
const delay = Math.min(findIdx(el) * 150, 500); | ||
setTimeout(() => { | ||
el.style.transform = 'translateY(0px)'; | ||
el.style.opacity = '1'; | ||
el.addEventListener('transitionend', done); | ||
}, delay); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<transition-group | ||
name="fade-slide-top-bottom" | ||
appear | ||
@before-appear="onBeforeEnter" | ||
@appear="onEnter" | ||
> | ||
<slot /> | ||
</transition-group> | ||
</template> | ||
|
||
<style lang="less"> | ||
.fade-slide-top-bottom-enter-active { | ||
transition: all 300ms ease-out; | ||
} | ||
.fade-slide-top-bottom-leave-active { | ||
transition: all 300ms ease-out; | ||
} | ||
.fade-slide-top-bottom-enter-from { | ||
transform: translateY(-20px); | ||
opacity: 0; | ||
} | ||
.fade-slide-top-bottom-leave-to { | ||
transform: translateY(20px); | ||
opacity: 0; | ||
} | ||
</style> |
25 changes: 25 additions & 0 deletions
25
packages/toolkits/pro/template/tinyvue/src/components/transition/transition-fade-down.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<template> | ||
<transition name="fade-slide-top-bottom" appear> | ||
<slot /> | ||
</transition> | ||
</template> | ||
|
||
<style lang="less"> | ||
.fade-slide-top-bottom-enter-active { | ||
transition: all 300ms ease-out; | ||
} | ||
.fade-slide-top-bottom-leave-active { | ||
transition: all 300ms ease-out; | ||
} | ||
.fade-slide-top-bottom-enter-from { | ||
transform: translateY(-20px); | ||
opacity: 0; | ||
} | ||
.fade-slide-top-bottom-leave-to { | ||
transform: translateY(20px); | ||
opacity: 0; | ||
} | ||
</style> |
31 changes: 31 additions & 0 deletions
31
...s/toolkits/pro/template/tinyvue/src/components/transition/transition-fade-slide-group.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script lang="ts" setup> | ||
import { findIdx } from './utils'; | ||
let count = 0; | ||
const onBeforeEnter = (el: HTMLElement) => { | ||
el.style.opacity = '0'; | ||
el.style.transform = 'translateX(-20px)'; | ||
el.style.transition = 'all 300ms ease-in-out'; | ||
count += 1; | ||
}; | ||
const onEnter = (el: HTMLElement, done: () => void) => { | ||
const delay = findIdx(el) * 150; | ||
setTimeout(() => { | ||
el.style.transform = 'translateX(0px)'; | ||
el.style.opacity = '1'; | ||
el.addEventListener('transitionend', done); | ||
}, delay); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<transition-group | ||
name="left-slide-fade" | ||
appear | ||
@appear="onEnter" | ||
@before-appear="onBeforeEnter" | ||
> | ||
<slot /> | ||
</transition-group> | ||
</template> |
25 changes: 25 additions & 0 deletions
25
packages/toolkits/pro/template/tinyvue/src/components/transition/transition-fade-slide.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<template> | ||
<transition name="left-slide-fade" appear> | ||
<slot /> | ||
</transition> | ||
</template> | ||
|
||
<style lang="less"> | ||
.left-slide-fade-enter-active { | ||
transition: all 300ms ease-out; | ||
} | ||
.left-slide-fade-leave-active { | ||
transition: all 300ms ease-out; | ||
} | ||
.left-slide-fade-enter-from { | ||
transform: translateX(-20px); | ||
opacity: 0; | ||
} | ||
.left-slide-fade-leave-to { | ||
transform: translateX(20px); | ||
opacity: 0; | ||
} | ||
</style> |
9 changes: 9 additions & 0 deletions
9
packages/toolkits/pro/template/tinyvue/src/components/transition/utils.ts
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const findIdx = (el: Element) => { | ||
let idx = 0; | ||
let cur = el; | ||
while (cur) { | ||
idx += 1; | ||
cur = cur.previousElementSibling; | ||
} | ||
return idx; | ||
}; |
8 changes: 6 additions & 2 deletions
8
packages/toolkits/pro/template/tinyvue/src/layout/page-layout.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,9 +1,13 @@ | ||
<template> | ||
<router-view v-slot="{ Component, route }"> | ||
<component :is="Component" :key="route.fullPath" /> | ||
<transition-fade-slide mode="out-in" appear> | ||
<component :is="Component" :key="route.fullPath" /> | ||
</transition-fade-slide> | ||
</router-view> | ||
</template> | ||
|
||
<script lang="ts" setup></script> | ||
<script lang="ts" setup> | ||
import transitionFadeSlide from '@/components/transition/transition-fade-slide.vue'; | ||
</script> | ||
|
||
<style scoped lang="less"></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
Oops, something went wrong.