question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trigger all <transition>s without a corresponding v-if/v-show on component mounting

See original GitHub issue

What problem does this feature solve?

A <transition> without a corresponding v-if/v-show not at the component’s template’s root will never be triggered. This may be by design, but it is confusing because a <transition> at the component’s template’s root does get triggered when the component is mounted.

What does the proposed API look like?

When the following modal’s template is mounted/destroyed, the dynamic fade-in-* classes are applied correctly, but the inner “slide-up” effect is never triggered. I propose that all <transition>s (including the inner ones) that do not have an associated v-for/v-if/etc be triggered on component mounting (& before destroy).

<template>
<transition name="fade-in">
  <div class="modal-backdrop">

    <transition name="slide-up">
      <div v-show="show" class="modal" role="dialog">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <slot></slot>
          </div>
        </div>
      </div>
    </transition>

  </div>
</transition>
</template>

Currently, I’m using the following workaround, with the parent calling the close method via $refs and listening for 'close' before destroying the modal.

<script>
export default {
  data() { return { show: false } },
  mounted() {
    this.show = true
  },
  methods: {
    close() {
      this.show = false
      this.$nextTick(() => this.$emit('close'))
    }
  }
}
</script>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
sirlancelotcommented, Sep 28, 2018

Does adding appear to the <transition> fix the problem?

2reactions
ezracellicommented, Sep 28, 2018

I will take this to StackOverflow, but here is a sandbox showing what I mean. The transition classes are applied to the inner transition properly on entering, but not on leaving. https://codesandbox.io/s/961npvk3o


enter


leave

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Transition Group - How to trigger animation for a ...
As far as I know, React Transition Groups works only in transition ... library to animate component when mounting like: React-animations.
Read more >
Animation transitions and triggers - Angular
This guide goes into depth on special transition states such as the * wildcard and void . It shows how these special states...
Read more >
Transition | Vue.js
Vue offers two built-in components that can help work with transitions and animations in response to changing state: <Transition> for applying animations ......
Read more >
Trigger effect only on mount - Learn React Hooks [Book]
Passing an empty array means that our effect function will only trigger once when the component mounts, and it will not trigger when...
Read more >
Advanced animation patterns with Framer Motion
A deep dive into Framer Motion's propagation, exit transitions and ... being set by the parent component, the animation does not trigger and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found