You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
2.1 KiB
JavaScript

Component({
data: {},
properties: {
// 抽屉高度
height: {
type: String,
value: "",
},
drawerType: {
type: String,
value: "",
},
//抽屉显示隐藏
show: {
type: Boolean,
value: false
},
titleText: {
type: String,
value: ''
},
// 是否需要显示tabbar
hideTabbar: {
type: Boolean,
value: false
},
cancerShow: {
type: Boolean,
value: true
},
//
touchClose: {
type: Boolean,
value: true
},
color: {
type: String,
value: '#fff'
},
},
methods: {
/**
* 阻止滑动穿透
*
*
*/
modalMove () {
console.log(this.data.color);
return false;
},
// 触摸开始事件
handletouchtart: function (event) {
this.data.lastX = event.touches[0].pageX;
this.data.lastY = event.touches[0].pageY;
},
filterTouchStart (event) {
this.handletouchtart(event);
},
filterTouchMove (event) {
let tx = this.handletouchmove(event);
if (this.data.touchClose) {
if (tx.ty > 100) {
this.hideLeft();
}
} else {
return false
}
},
hideLeft () {
// this.data.show = false
// this.setData({
// show: false
// })
var eventDetail = {
type: this.data.drawerType
};
this.triggerEvent("hidedrawer", eventDetail);
if (this.data.hideTabbar) {
setTimeout(() => {
this.getTabBar().setData({
isShow: true,
});
}, 200);
}
},
/**
* 页面滑动事件监听
*
*
*/
handletouchmove: function (event) {
let that = this;
var currentX = event.touches[0].pageX;
var currentY = event.touches[0].pageY;
var tx = currentX - this.data.lastX;
var ty = currentY - this.data.lastY;
var text = "";
//左右方向滑动
if (Math.abs(tx) > Math.abs(ty)) {
return {
tx,
};
}
//上下方向滑动
else {
return {
ty,
};
}
},
}
})