Skip to content

Instantly share code, notes, and snippets.

@davision
Created March 5, 2018 14:06
Show Gist options
  • Save davision/56f1f594ce4d62f45d2787962ffdb904 to your computer and use it in GitHub Desktop.
Save davision/56f1f594ce4d62f45d2787962ffdb904 to your computer and use it in GitHub Desktop.
Encapsulated wrapper transition component
<template>
<transition name="fade" v-bind="$attrs" v-on="$listeners">
<slot></slot>
</transition>
</template>
<script>
export default {};
</script>
<style>
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.3s;
}
.fade-enter,
.fade-leave-to {
opacity: 0;
}
</style>
...
<fade-transition mode="out-in">
<div key="blue" v-if="show" class="box"></div>
<div key="red" v-else class="red-box"></div>
</fade-transition>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment