A Pen by Edward Lance Lorilla on CodePen.
-
-
Save rascoop/3ed241ef7747ad93cc2280cdc93b5ce4 to your computer and use it in GitHub Desktop.
vuejs velocityjs transition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template id='image'> | |
<img ref="imgs" alt=""/> | |
</template> | |
<div id="app"> | |
<transition mode="out-in" | |
v-on:before-enter="beforeEnter" | |
v-on:enter="enter" | |
v-on:leave="leave" | |
> | |
<div ref="container" class="container" :key="show"> | |
<div key="box" v-if="show" ref="box"> | |
<imgs ref="imgs" src="http://via.placeholder.com/350x150" alt=""> </imgs> | |
<div class="inner"> | |
<div @click="show = false" class="btn">Show Modal</div> | |
</div> | |
</div> | |
<div key="pop" ref="pop" v-else> | |
<div @click="show = true" class="close">×</div> | |
<imgs src="http://via.placeholder.com/350x150" alt=""></imgs> | |
</div> | |
</div> | |
</transition> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.component("imgs", { | |
template: "#image", | |
mounted(){ | |
//pre-register transition | |
Velocity(this.$refs.imgs, 'transition.slideUpIn', {duration: 1500} ) | |
} | |
}); | |
new Vue({ | |
el: '#app', | |
data(){ | |
return{ | |
show: true | |
} | |
}, | |
mounted(){ | |
var vm = this | |
Velocity.RegisterUI('mqs.slideUpIn', { | |
defaultDuration: 500, | |
calls: [ | |
[{opacity: [1, 0], translateY: [0, 100]}] | |
] | |
}) | |
Velocity.RegisterUI('mqs.slideDownOut', { | |
defaultDuration: 300, | |
calls: [ | |
[{opacity: [0, 1], translateY: [100, 0]}] | |
] | |
}) | |
}, | |
methods:{ | |
beforeEnter: function (el) { | |
el.style.opacity = "0%" | |
}, | |
enter: function (el, done) { | |
Velocity(el, 'mqs.slideUpIn', {complete: done} ) | |
}, | |
leave: function (el, done) { | |
Velocity(el, 'mqs.slideDownOut', {complete: done} ) | |
} | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.5.0/velocity.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.5.0/velocity.ui.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.3/vue.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#app { | |
text-align: center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment