xxx.wxml
<view class="btn" bindtap="powerDrawer" data-statu="open">button</view>
<view class="drawer_screen" bindtap="powerDrawer" data-statu="close" wx:if="{{showModalStatus}}"></view>
<view animation="{{animationData}}" class="drawer_attr_box" wx:if="{{showModalStatus}}">
<view class="drawer_content">
<view class="drawer_title line">菜单1</view>
<view class="drawer_title line">菜单2</view>
<view class="drawer_title line">菜单3</view>
<view class="drawer_title line">菜单4</view>
<view class="drawer_title">菜单5</view>
</view>
</view>
xxx.wxss
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
.btn {
width: 80%;
padding: 20rpx 0;
border-radius: 10rpx;
text-align: center;
margin: 40rpx 10%;
background: #0C1939;
color: #fff;
}
.drawer_screen {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 1000;
background: #000;
opacity: 0.2;
overflow: hidden;
}
.drawer_attr_box {
width: 100%;
overflow: hidden;
position: fixed;
bottom: 0;
left: 0;
z-index: 1001;
background: #fff;
right: 0;
}
.drawer_content {
padding: 20rpx 40rpx;
height: 470rpx;
overflow-y: scroll;
}
.drawer_title{
padding:20rpx;
font:42rpx "microsoft yahei";
text-align: center;
}
.line{
border-bottom: 1px solid #f8f8f8;
}
xxx.js
Page({
data: {
showModalStatus: false
},
powerDrawer: function (e) {
var currentStatu = e.currentTarget.dataset.statu;
this.util(currentStatu)
},
util: function (currentStatu) {
var animation = wx.createAnimation({
duration: 200,
timingFunction: "linear",
delay: 0
});
this.animation = animation;
animation.translateY(240).step();
this.setData({
animationData: animation.export()
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation
})
if (currentStatu == "close") {
this.setData(
{
showModalStatus: false
}
);
}
}.bind(this), 200)
if (currentStatu == "open") {
this.setData(
{
showModalStatus: true
}
);
}
}
})