add app-shell, master-detail, pane-transition
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import view from "./index.vue";
|
||||
import { WebToolkit } from "timi-web";
|
||||
|
||||
export const PaneTransition = WebToolkit.withInstall(view);
|
||||
export default PaneTransition;
|
||||
@@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<transition :name="transitionName" :css="direction !== 'none'">
|
||||
<slot />
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import type { PaneDirection } from "../../composables/use-master-detail";
|
||||
|
||||
defineOptions({
|
||||
name: "PaneTransition"
|
||||
});
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
/**
|
||||
* 切换方向。
|
||||
*
|
||||
* - forward:新内容从右侧推入,旧内容左移让位(进入下一层,如详情 → 编辑)
|
||||
* - back:新内容从左侧覆盖回来,旧内容滑出右侧(返回上一层)
|
||||
* - none:同级内容替换(换一个客户),直接切换不做动画
|
||||
*/
|
||||
direction?: PaneDirection;
|
||||
}>(), {
|
||||
direction: "forward"
|
||||
});
|
||||
|
||||
defineSlots<{
|
||||
default?: () => unknown;
|
||||
}>();
|
||||
|
||||
const transitionName = computed(() => `tui-pane-${props.direction}`);
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
/**
|
||||
* 栏内推入/推出效果,与 PageTransition 的 push-left / push-right 同源,
|
||||
* 区别是容器从视口换成了栏位:定位用 absolute 而非 fixed,时长略短。
|
||||
*
|
||||
* 这里不能用 scoped:过渡类是由 Vue 加到插槽内容上的,scoped 命中不了。
|
||||
*/
|
||||
@duration: 420ms;
|
||||
@easing: var(--tui-bezier, cubic-bezier(.19, 1, .22, 1));
|
||||
@offset: 25%;
|
||||
@shadow: -4px 0 16px rgba(0, 0, 0, .15);
|
||||
|
||||
// forward:新内容从右侧推入,旧内容左移
|
||||
.tui-pane-forward-enter-active,
|
||||
.tui-pane-forward-leave-active {
|
||||
position: absolute !important;
|
||||
inset: 0;
|
||||
transition: transform @duration @easing, opacity .2s linear;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
|
||||
.tui-pane-forward-enter-from {
|
||||
box-shadow: @shadow;
|
||||
transform: translate3d(100%, 0, 0);
|
||||
}
|
||||
|
||||
.tui-pane-forward-leave-to {
|
||||
filter: brightness(.98);
|
||||
transform: translate3d(-@offset, 0, 0);
|
||||
}
|
||||
|
||||
// back:新内容从左侧覆盖回来,旧内容滑出右侧
|
||||
.tui-pane-back-enter-active,
|
||||
.tui-pane-back-leave-active {
|
||||
position: absolute !important;
|
||||
inset: 0;
|
||||
transition: transform @duration @easing;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
|
||||
.tui-pane-back-enter-active {
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.tui-pane-back-enter-from {
|
||||
transform: translate3d(-@offset, 0, 0);
|
||||
}
|
||||
|
||||
.tui-pane-back-leave-active {
|
||||
z-index: 1;
|
||||
transition: transform @duration @easing, box-shadow .3s;
|
||||
}
|
||||
|
||||
.tui-pane-back-leave-to {
|
||||
box-shadow: @shadow;
|
||||
transform: translate3d(100%, 0, 0);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user