windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Vue.js transition and transition-group animations not working

Asked By: Anonymous

I have a Vue 2 Carousel component, with Slide child components generated using v-for. Slides are displayed and hidden using v-show. I cannot get CSS transitions between Slides to work.

I tried wrapping the Slides in <transition> but mode=out-in does nothing and I end up with two Slides in the Carousel during transition, one fading in, the other out. When I wrap the Slides in a <transition-group>, CSS transitions don’t show at all, Slides are just replaced.

I looked at transitioning between components, but Slides are generated based on a list of links from an API and I don’t see a way of combining dynamic generation with this solution.

Here’s a JSFiddle with the issue


Solution

Answered By: Anonymous

If you do not intend to crossfade the images (i.e. only one image is actually on the screen at any given point of time), you can restructure your code such as only a single <Slide> component is rendered at a single time. You simply assign a unique key that is dynamically updated, e.g. your active data of the slider component.

Your template will now look like this:

<div class="carousel-wrapper" id="promotions">
    <transition name="component-fade" mode="out-in">
        <!-- Bind image url dynamically, bind key to active index -->
        <Slide class="slide" :url="imageUrl" :key="active"></Slide>
    </transition>
</div>

The imageUrl is simply a computed property that returns the image URL by index:

imageUrl() {
    return this.list[this.active].url;
}

The Slide component should be as “dumb” as we need it to: in this case, it simply receives the dynamically-bound image URL and nothing more:

<div>
    <img :src="url" class="image">
</div>

Note:

  • you should use a transition duration that is equal to, or shorter than, the time interval of your active property updates. In your original code the slides are cycled ever 3s but the transition-duration is set to 4s, leading to really janky transitions
  • the solution will be more complicated if you want a crossfade animation.

Here is a proof-of-concept example:

_x000D_

_x000D_

Vue.component('Slide', {_x000D_
  template: `_x000D_
    <div>_x000D_
        <img :src="url" class="image">_x000D_
    </div>`,_x000D_
  props: ['url']_x000D_
});_x000D_
_x000D_
Vue.component('component-2', {_x000D_
  template: `<div>_x000D_
                    <p>component 2</p>_x000D_
                 </div>`_x000D_
});_x000D_
_x000D_
new Vue({_x000D_
  el: '#example',_x000D_
  template: `_x000D_
  <div class="carousel-wrapper" id="promotions">_x000D_
        <transition name="component-fade" mode="out-in">_x000D_
            <Slide class="slide" :url="imageUrl" :key="active">_x000D_
            </Slide>_x000D_
        </transition>_x000D_
  </div>`,_x000D_
  data() {_x000D_
    return {_x000D_
      list: [{_x000D_
          url: 'https://static.pexels.com/photos/572741/pexels-photo-572741.jpeg'_x000D_
        },_x000D_
        {_x000D_
          url: 'https://static.pexels.com/photos/575739/pexels-photo-575739.jpeg'_x000D_
        },_x000D_
        {_x000D_
          url: 'https://static.pexels.com/photos/576832/pexels-photo-576832.jpeg'_x000D_
        }_x000D_
      ],_x000D_
      active: 0_x000D_
    }_x000D_
  },_x000D_
  computed: {_x000D_
    numberOfSlides() {_x000D_
      return this.list.length - 1_x000D_
    },_x000D_
    imageUrl() {_x000D_
      return this.list[this.active].url;_x000D_
    }_x000D_
  },_x000D_
  created() {_x000D_
    this.rotate()_x000D_
  },_x000D_
  methods: {_x000D_
    moveSlide(event) {_x000D_
      this.active = event.srcElement.dataset.slide_x000D_
      this.list.forEach(el => {_x000D_
        el.active = false_x000D_
      })_x000D_
      this.list[event.srcElement.dataset.slide].active = true_x000D_
    },_x000D_
    rotate() {_x000D_
      if (this.active < this.numberOfSlides) {_x000D_
        this.active = this.active + 1_x000D_
      } else {_x000D_
        this.active = 0_x000D_
      }_x000D_
      let _this = this_x000D_
      setTimeout(_this.rotate, 3000)_x000D_
    }_x000D_
  }_x000D_
});

_x000D_

.carousel-wrapper {_x000D_
  width: 100%;_x000D_
  display: flex;_x000D_
  flex-direction: column;_x000D_
  justify-content: center;_x000D_
  align-items: center;_x000D_
  height: 100%;_x000D_
}_x000D_
_x000D_
.carousel {}_x000D_
_x000D_
.dots {_x000D_
  max-width: 100%;_x000D_
  display: flex;_x000D_
  flex-direction: row;_x000D_
  justify-content: center;_x000D_
  align-items: center;_x000D_
  position: absolute;_x000D_
  bottom: 2em;_x000D_
  z-index: 1;_x000D_
}_x000D_
_x000D_
.dot {_x000D_
  height: 1em;_x000D_
  width: 1em;_x000D_
  margin: 0 1em 0 1em;_x000D_
  border-radius: 50%;_x000D_
  background-color: red;_x000D_
}_x000D_
_x000D_
.component-fade-enter-active,_x000D_
.component-fade-leave-active {_x000D_
  transition: opacity 1s ease;_x000D_
}_x000D_
_x000D_
.component-fade-enter,_x000D_
.component-fade-leave-to {_x000D_
  opacity: 0;_x000D_
}_x000D_
_x000D_
.slide {_x000D_
  width: 100%;_x000D_
  height: 650px;_x000D_
}_x000D_
_x000D_
.image {_x000D_
  max-width: 100%;_x000D_
  max-height: 650px;_x000D_
}

_x000D_

<a href="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.4/vue.min.js">https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.4/vue.min.js</a>_x000D_
<div id="example">_x000D_
</div>

_x000D_

_x000D_

x000D

techinplanet staff

instagram volgers kopen volgers kopen buy windows 10 pro buy windows 11 pro


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort Çanakkale escort Aydın escort Muğla escort Tekirdağ escort Manisa escort Balıkesir escort Trabzon escort Elazığ escort Ordu escort Kütahya escort Isparta escort Rize escort Kahramanmaraş escort Yalova escort Giresun escort Yozgat escort Tokat escort Şanlıurfa escort Sivas escort Batman escort Erzurum escort Sinop escort Kırşehir escort Karaman escort Kırıkkale escort Bolu escort Amasya escort Niğde escort Uşak escort Edirne escort Çorum escort Osmaniye escort Zonguldak escort Van escort Erzincan escort Söke escort Bodrum escort Çerkezköy escort Akhisar escort Bandırma escort Ayvacık escort Akçaabat escort Karakoçan escort Altınordu escort Tavşanlı escort Eğirdir escort Ardeşen escort Afşin escort Altınova escort Bulancak escort Sorgun escort Erbaa escort Viranşehir escort Zara escort Kozluk escort Aziziye escort Ayancık escort Kaman escort Ermenek escort Keskin escort Gerede escort Göynücek escort Bor escort Banaz escort Havsa escort Osmancık escort Bahçe escort Alaplı escort Başkale escort Kemah escort Nazilli escort Fethiye escort Çorlu escort Alaşehir escort Altıeylül escort Biga escort Araklı escort Kovancılar escort Fatsa escort Simav escort Yalvaç escort Çayeli escort Dulkadiroğlu escort Çiftlikköy escort Espiye escort Sarıkaya escort Niksar escort Suruç escort Yıldızeli escort Sason escort Horasan escort Boyabat escort Mucur escort Sarıveliler escort Yahşihan escort Göynük escort Gümüşhacıköy escort Çamardı escort Eşme escort İpsala escort Sungurlu escort Hasanbeyli escort Çaycuma escort İpekyolu escort Refahiye escort Kuşadası escort Marmaris escort Süleymanpaşa escort Turgutlu escort Susurluk escort Gelibolu escort Of escort Ünye escort Domaniç escort Fındıklı escort Elbistan escort Çınarcık escort Tirebolu escort Akdağmadeni escort Turhal escort Eyyübiye escort Suşehri escort Yakutiye escort Gerze escort Mengen escort Merzifon escort Ulukışla escort Sivaslı escort Keşan escort Kadirli escort Ereğli escort Özalp escort Tercan escort Efeler escort Didim escort Çine escort Dalaman escort Menteşe escort Milas escort Ortaca escort Seydikemer escort Ergene escort Kapaklı escort Malkara escort Salihli escort Şehzadeler escort Soma escort Yunusemre escort Ayvalık escort Bigadiç escort Burhaniye escort Gönen escort Karesi escort Çan escort Yenice escort Ortahisar escort Yomra escort Perşembe escort Pazar escort Onikişubat escort Pazarcık escort Türkoğlu escort Eynesil escort Görele escort Piraziz escort Yağlıdere escort Çayıralan escort Boğazlıyan escort Zile escort Siverek escort Karaköprü escort Haliliye escort Akçakale escort Şarkışla escort Gemerek escort Oltu escort Palandöken escort Mudurnu escort Suluova escort Taşova escort Toprakkale escort Kilimli escort Tuşba escort Üzümlü escort