xml
<scroll-view class='extra-word' scroll-y="{{isScroll}}">
//頁面內容
</scroll-view>
js
Page({
// 頁面的初始數據
data: {
isScroll: true
},
sidebarDrawer: function (e) {
var currentStatu = e.currentTarget.dataset.statu;
this.side(currentStatu)
},
side: function (currentStatu) {
/* 動畫部分 */
// 第1步:創建動畫實例
var animation = wx.createAnimation({
duration: 6000, //動畫時長
timingFunction: "linear", //線性
delay: 0 //0則不延遲
});
// 第2步:這個動畫實例賦給當前的動畫實例
this.animation = animation;
// 第3步:執行第一組動畫
animation.translateX(-234).step();
// 第4步:導出動畫對象賦給數據對象儲存
this.setData({
animationData: animation.export()
})
//關閉
if (currentStatu == "close") {
this.setData(
{
showSideStatus: false,
isScroll: true
}
);
}
// 顯示
if (currentStatu == "open") {
this.setData(
{
showSideStatus: true,
isScroll: "{{false}}"}//只有{{false}}才能起作用,用false沒反應
);
}
}
})