V
V
VegasChickiChicki2019-08-13 04:13:42
Vue.js
VegasChickiChicki, 2019-08-13 04:13:42

How to delay animation of transition element?

The bottom line is that there are 3 blocks, they have one animation, when you open the page using the property
appear, these animations work immediately, but you need them to work in turn.
That is, the first, after 1s the second, after 2s the third. I can't figure out how to implement it. How to "tell" the transition element that the start should be delayed by n seconds.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2019-08-15
@VegasChickiChicki

Render elements with a delay :

data: () => ({
  items: [
    { show: false, ... },
    { show: false, ... },
    ...
  ],
}),
computed: {
  showItems() {
    return this.items.filter(n => n.show);
  },
},
mounted() {
  this.items.forEach((n, i) => setTimeout(() => n.show = true, i * 1000));
},

<transition-group name="fade">
  <div v-for="n in showItems" :key="n.id">{{ n }}</div>
</transition-group>

H
hzzzzl, 2019-08-13
@hzzzzl

via css?

.anim-block:nth-of-type(1) {  transition-delay: 0s;  }
.anim-block:nth-of-type(2) {  transition-delay: 1s;  }
.anim-block:nth-of-type(3) {  transition-delay: 2s;  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question