MohamedT
MohamedT

Reputation: 13

Why elements appears from top-left corner with TransitionGroup in Vue 3?

I'm currently trying to integrate animations on a small component that contains: a title, an image and a block of buttons.

The rules are as follows:

At present, for some unknown reason, the components (title and buttons) systematically come from the top left corner of the page. What's more, the image is only animated when the hover stops, not when it starts.

Here's a link to the VueJS playground to show you how it works

Your help will be greatly appreciated

I already tried :

Upvotes: 1

Views: 611

Answers (1)

Moritz Ringler
Moritz Ringler

Reputation: 16061

When you use v-if instead of v-show, the elements stop coming in from the top left. Also, I think type="animation" is only necessary when you use CSS animations and transitions together, but you are only using transitions.

Finally, you can position the where you want to move them from and to. To smoothen the transition, use absolute position on the leaving elements, so the space is vacated immediately:

.slide-fade-leave-active{
  position: absolute;
}
.slide-fade-enter-from,
.slide-fade-leave-to {
  opacity: 0;
  transform: translateY(-100px);
}

Here it is in a playground. Hope it helps

Upvotes: 1

Related Questions