微信小程序animation實現列表滑動展現展現

需求:
實現以下效果
20200502_233357.gifgit

實現:
定義參數github

option:{
    duration: 100, // 動畫執行時間
    timingFunction: 'ease-in'  // 動畫執行效果
}

定義animation
image.png動畫

設置初始不展現:this

.commonInner {
    height:0;
    overflow:  hidden;
}

展開方法:spa

open:function(){
    let me=this;
    var box = wx.createAnimation(me.data.option);//初始化animation
    let hei=40*4;//可設置動態獲取高度
    box.height(hei).step();//設置動畫效果
    me.setData({
        inner: box.export(),
        openFlag:true//判斷當前狀態(展開/收起)
    })
}

收起方法:code

close: function () {
    let me = this;
    var box = wx.createAnimation(me.data.option);
    box.height(0).step();
    me.setData({
        inner: box.export(),
        openFlag: false
    })
}

代碼地址: https://github.com/myweiwei/s...
將不斷更新完善,期待您的批評指正!blog

相關文章
相關標籤/搜索