2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2020-02-06 12:11:14 +02:00
|
|
|
<transition-group v-if="$store.state.device.animation"
|
2020-01-29 21:37:25 +02:00
|
|
|
name="staggered-fade"
|
|
|
|
tag="div"
|
|
|
|
:css="false"
|
|
|
|
@before-enter="beforeEnter"
|
|
|
|
@enter="enter"
|
|
|
|
@leave="leave"
|
|
|
|
mode="out-in"
|
|
|
|
appear
|
|
|
|
>
|
|
|
|
<slot></slot>
|
|
|
|
</transition-group>
|
2020-02-06 12:11:14 +02:00
|
|
|
<div v-else>
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
2020-01-29 21:37:25 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
props: {
|
|
|
|
delay: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 40
|
|
|
|
},
|
|
|
|
direction: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 'down'
|
2020-02-06 07:23:01 +02:00
|
|
|
},
|
|
|
|
reversed: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
},
|
2020-02-06 10:02:32 +02:00
|
|
|
i: 0,
|
2020-01-29 21:37:25 +02:00
|
|
|
methods: {
|
|
|
|
beforeEnter(el) {
|
|
|
|
el.style.opacity = 0;
|
|
|
|
el.style.transform = this.direction === 'down' ? 'translateY(-64px)' : 'translateY(64px)';
|
2020-02-06 10:02:32 +02:00
|
|
|
let index = this.$options.i;
|
|
|
|
const delay = this.delay * index;
|
|
|
|
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++;
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
enter(el, done) {
|
|
|
|
setTimeout(() => {
|
|
|
|
el.style.opacity = 1;
|
|
|
|
el.style.transform = 'translateY(0px)';
|
2020-02-06 10:02:32 +02:00
|
|
|
el.addEventListener('transitionend', () => {
|
|
|
|
el.style.transition = '';
|
|
|
|
this.$options.i--;
|
2020-02-06 07:23:01 +02:00
|
|
|
done();
|
2020-02-06 10:02:32 +02:00
|
|
|
}, { once: true });
|
|
|
|
});
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
2020-02-06 10:02:32 +02:00
|
|
|
leave(el) {
|
2020-02-06 07:55:27 +02:00
|
|
|
el.style.opacity = 0;
|
|
|
|
el.style.transform = this.direction === 'down' ? 'translateY(64px)' : 'translateY(-64px)';
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
focus() {
|
|
|
|
this.$slots.default[0].elm.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.staggered-fade-move {
|
|
|
|
transition: transform 0.7s !important;
|
|
|
|
}
|
|
|
|
</style>
|