radical-dreamers / animated-vue

A plugin to use animate.css animations as Vue2 transitions
MIT License
220 stars 19 forks source link

Delay on v-if="false" #6

Closed cirience-zz closed 7 years ago

cirience-zz commented 7 years ago

Hello,

I don't know wheather is it a bug or a feature. I decided to open an issue for this. Please forgive me, if my opened issue is not accurate.

I'm experiencing an little delay when I'm hiding an element with the v-if="false" tag. I'm providing an gif for you. IGif with "bug"

My template source-code follows, so you can understand how the bug came off.

<div class="i18n_picker">
   <div class="i18n_icon" v-on:click="i18nListVisible = !i18nListVisible">
      <animated-group-bounce-in tag="div">
         <img :key="returnLocaleInfo[activeLocale].langcode" :src="returnLocaleInfo[activeLocale].flag" :alt="returnLocaleInfo[activeLocale].langname"/>
      </animated-group-bounce-in>
      <i class="material-icons langarrow">keyboard_arrow_down</i>
   </div>
   <animated-flip-in-x>
      <ul v-if="i18nListVisible">
         <li :key="localeInfoItem.langcode" v-for="localeInfoItem in returnInactiveLocaleInfo">
            <div class="flag_container" v-on:click="changeLocale(localeInfoItem.langcode)"><img :src="localeInfoItem.flag" :alt="localeInfoItem.langname"/></div>
         </li>
      </ul>
   </animated-flip-in-x>
</div>

And the method to hide the picker

methods: {
    changeLocale: function (locale) {
      this.i18nListVisible = !this.i18nListVisible
      this.$locale.change(locale)
    }
  }
dragonautdev commented 7 years ago

Hey @SHA-256

Thanks a lot for using this plugin!

I believe the delay might not be caused by the plugin itself, but the combination of v-if, animate.css' default animations delay and whatever events setting this.$locale triggers.

Let me ellaborate a bit on that:

A few things to try before we confirm it's a bug on the plugin or something related to the above:

  1. Use v-show instead of v-if, as it's more lightweight (it just sets the element's visibility).
  2. Please remove the this.$locale.change... invocation in your click handler so we can discard the delay is related to events/actions triggered by it.

Please let me know how things go after making those changes and don't hesitate asking any questions you need!

cirience-zz commented 7 years ago

Everything is working fine now. Thank you very much for your detailed answer.