Update sequential-entrance.vue

This commit is contained in:
syuilo 2020-02-15 18:39:45 +09:00
parent 24453ebcc3
commit 742889a035
1 changed files with 37 additions and 41 deletions

View File

@ -1,12 +1,10 @@
<template> <template>
<transition-group v-if="$store.state.device.animation" <transition-group v-if="$store.state.device.animation"
name="staggered-fade" class="uupnnhew"
:data-direction="direction"
:data-reversed="reversed ? 'true' : 'false'"
name="staggered"
tag="div" tag="div"
:css="false"
@before-enter="beforeEnter"
@enter="enter"
@leave="leave"
mode="out-in"
appear appear
> >
<slot></slot> <slot></slot>
@ -37,48 +35,46 @@ export default Vue.extend({
default: false default: false
} }
}, },
i: 0,
methods: { methods: {
beforeEnter(el) {
if (document.hidden) return;
el.style.opacity = 0;
el.style.transform = this.direction === 'down' ? 'translateY(-64px)' : 'translateY(64px)';
const delay = this.delay * this.$options.i;
el.style.transition = [getComputedStyle(el).transition, `transform 0.7s cubic-bezier(0.23, 1, 0.32, 1) ${delay}ms`, `opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1) ${delay}ms`].filter(x => x != '').join(',');
this.$options.i++;
setTimeout(() => {
el.style.transition = null;
el.style.transform = null;
el.style.opacity = null;
this.$options.i--;
}, delay + 710);
},
enter(el) {
if (document.hidden) {
el.style.opacity = 1;
el.style.transform = 'translateY(0px)';
} else {
setTimeout(() => { //
el.style.opacity = 1;
el.style.transform = 'translateY(0px)';
});
}
},
leave(el) {
el.style.opacity = 0;
el.style.transform = this.direction === 'down' ? 'translateY(64px)' : 'translateY(-64px)';
},
focus() { focus() {
this.$slots.default[0].elm.focus(); this.$slots.default[0].elm.focus();
} }
} },
}); });
</script> </script>
<style lang="scss"> <style lang="scss">
.staggered-fade-move { .staggered-move {
transition: transform 0.7s !important; transition: all 0.7s cubic-bezier(0.23, 1, 0.32, 1) !important;
}
.uupnnhew[data-direction="up"] {
.staggered-enter {
opacity: 0;
transform: translateY(64px);
}
}
.uupnnhew[data-direction="down"] {
.staggered-enter {
opacity: 0;
transform: translateY(-64px);
}
}
.uupnnhew[data-reversed="true"] {
@for $i from 1 through 30 {
.staggered-enter-active:nth-last-child(#{$i}) {
transition: all 0.7s cubic-bezier(0.23, 1, 0.32, 1) (15ms * ($i - 1));
}
}
}
.uupnnhew[data-reversed="false"] {
@for $i from 1 through 30 {
.staggered-enter-active:nth-child(#{$i}) {
transition: all 0.7s cubic-bezier(0.23, 1, 0.32, 1) (15ms * ($i - 1));
}
}
} }
</style> </style>