vueè¿åº¦ææ å¨ç»
程序员文章站
2022-05-02 20:05:40
...
Vueæ¡æ¶ä½¿ç¨css3è¿æ¸¡ææææ¯jså¨ç»
Vueå é¨æä¾äºä¸ä¸ªå«åtransitionçè¿æ¸¡ç»ä»¶
使ç¨transitionå 裹è¿æ¸¡å ç´ ï¼é£ä¹ä¼èªå¨æ·»å 6 个类å 8个é©åå½æ°
- é»è®¤ ç±»å å¼å¤´ v
- å¦æænameå±æ§ï¼é£ä¹ä½¿ç¨ è¿ä¸ªnameå±æ§å¼ä½ä¸ºç±»åå¼å¤´
- å®ç°æ¹å¼
- å¨ CSS è¿æ¸¡åå¨ç»ä¸èªå¨åºç¨ class ã èªå·±å ã
- å¯ä»¥é å使ç¨ç¬¬ä¸æ¹ CSS å¨ç»åºï¼å¦ Animate.css
- å¨è¿æ¸¡é©åå½æ°ä¸ä½¿ç¨ JavaScript ç´æ¥æä½ DOM
- å¯ä»¥é å使ç¨ç¬¬ä¸æ¹ JavaScript å¨ç»åºï¼å¦ Velocity.js
- 第ä¸ç§ [ å¨ CSS è¿æ¸¡åå¨ç»ä¸èªå¨åºç¨ class ã èªå·±å ã ]
- 第äºç§ï¼ animate.css ã æ¨è ã
- 第ä¸ç§ï¼ Vueæä¾äº8个javascripté©åï¼æ们éè¦èªå®ä¹jså¨ç»
- 第åç§ï¼ 使ç¨ç¬¬ä¸æ¹æä»¶ï¼ Velocity.js
第ä¸ç§
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
<style>
.slide-fade-enter-active {
transition: all .3s ease;
}
.slide-fade-leave-active {
transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
transform: translateX(100px);
opacity: 0;
}
</style>
</head>
<body>
<div id="app">
<button @click = "flag = !flag"> ç¹å» </button>
<transition name = "slide-fade">
<p v-if = "flag"> å¨ç»å
ç´ </p>
</transition>
</div>
</body>
<script>
new Vue({
el: '#app',
data: {
flag: true
}
})
</script>
</html>
第äºç§
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link href="https://cdn.bootcss.com/animate.css/3.7.2/animate.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
</head>
<body>
<div id="app">
<button @click = "flag = !flag"> ç¹å» </button>
<transition name = "slide-fade"
enter-active-class = "animated bounceIn"
leave-active-class = "animated bounceOut"
>
<p v-if = "flag"> å¨ç»å
ç´ </p>
</transition>
</div>
</body>
<script>
new Vue({
el: '#app',
data: {
flag: true
}
})
</script>
</html>
第ä¸
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.2.3/velocity.min.js"></script>
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
</head>
<body>
<div id="app">
<button @click="show =!show">
Toggle
</button>
<transition
v-on:before-enter="beforeEnter"
v-on:enter="enter"
v-on:leave="leave"
v-bind:css="false"
>
<p v-if="show">
Demo
</p>
</transition>
</div>
</body>
<script>
new Vue({
el: '#app',
data: {
show: true
},
methods: {
beforeEnter: function (el) {
el.style.opacity = 0
el.style.transformOrigin = 'left'
},
enter: function (el, done) {
Velocity(el, { opacity: 1, fontSize: '1.4em' }, { duration: 300 })
Velocity(el, { fontSize: '1em' }, { complete: done })
},
leave: function (el, done) {
Velocity(el, { translateX: '15px', rotateZ: '50deg' }, { duration: 600 })
Velocity(el, { rotateZ: '100deg' }, { loop: 2 })
Velocity(el, {
rotateZ: '45deg',
translateY: '30px',
translateX: '30px',
opacity: 0
}, { complete: done })
Velocity( el, { translateX: '100px' }, { duration: 1000 })
}
}
})
</script>
</html>
上一篇: LinearLayout的动画效果
下一篇: jQuery的动画效果