const app = getApp()
Page({
data: {
hideModal: true,
animationData: {},
},
onLoad: function () {
},
showModal: function () {
var that=this;
that.setData({
hideModal:false
})
var animation = wx.createAnimation({
duration: 600,
timingFunction: 'ease',
})
this.animation = animation
setTimeout(function(){
that.fadeIn();
},200)
},
hideModal: function () {
var that=this;
var animation = wx.createAnimation({
duration: 800,
timingFunction: 'ease',
})
this.animation = animation
that.fadeDown();
setTimeout(function(){
that.setData({
hideModal:true
})
},720)
},
fadeIn:function(){
this.animation.translateY(0).step()
this.setData({
animationData: this.animation.export()
})
},
fadeDown:function(){
this.animation.translateY(600).step()
this.setData({
animationData: this.animation.export(),
})
},
})
<view class="modals modals-bottom-dialog" hidden="{{hideModal}}">
<view class="modals-cancel" bindtap="hideModal"></view>
<view class="bottom-dialog-body bottom-pos" animation="{{animationData}}">
<view>dssasdfsfsd</view>
</view>
</view>
<button bindtap="showModal">点我</button>
.bottom-pos{-webkit-transform:translateY(100%);transform:translateY(100%);}
.modals{position:fixed; z-index: 999; top:0; left: 0; right:0; bottom: 0;}
.modals-cancel{position:absolute; z-index:1000; top:0; left: 0; right:0; bottom: 0; background-color: rgba(0,0,0,.5);}
.bottom-dialog-body{position:absolute; z-index:10001; bottom:0; left:0; right:0; padding:30rpx; height:80vh; background-color: #fff;}