|
小程序動畫插件,更方便地將所需的動畫css注入到對應的元素中,使動畫邏輯更可控
import {Animation, AnimationGroup, AnimationAssign} from '../../Animation/Animation';wxml 中添加
//Animation
.fadeOutToButton-enter{
opacity: 0.01;
transform: translateY(-50%);
}
.fadeOutToButton-enter.fadeOutToButton-enter-active{
opacity: 1;
transform: translateY(0);
transition: all 1000ms ease-in;
}
.fadeOutToButton-exit{
opacity: 1;
transform: translateY(0);
}
.fadeOutToButton-exit.fadeOutToButton-exit-active{
opacity: 0.01;
transform: translateY(50%);
transition: all 1000ms ease-in;
}初始化 在onLoad 函數(shù)中:
onLoad:function(options){
//Animation
this.fadeOutToButton = new Animation(this,{
className: 'fadeOutToButton', // 寫在css的樣式名
animationName: 'fade', // 填寫在html中的變量名
timeOut: 1000, //動畫時間 和動畫持續(xù)時間同步
// delayTime: 1000, // 延遲時間
})
//AnimationGroup
this.fadeArr = new AnimationGroup(this,{
className: 'fadeOutToButton', // 寫在css的樣式名
animationName: 'fadeArr', // 填寫在html中的變量名
timeOut: 1000, //動畫時間 和動畫持續(xù)時間同步
// delayTime: 1000, // 延遲時間
interval: 200,
})
//AnimationAssign
this.removeAnimation = new AnimationAssign(this,{
className: 'fadeOutToButton',
animationName: 'fadeArr',
timeOut:1000,
})
},調(diào)用 在 onShow 函數(shù)中: (當元素一開始存在時)
onShow: function () {
this.fadeOutToButton.in()
},
當元素開始并不存在 (會先顯示元素之前先添加上 enter類)
// 可傳入延遲時間 毫秒 不填會根據(jù)構造時的延遲時間來控制
this.fadeOutToButton.in(1000).then(()=>{
this.setData({
boxShow: true,
})
})
消除元素 (會先元素消失之后在消失元素)
this.fadeOutToButton.out().then(()=>{
this.setData({
boxShow: false,
})
})
|