js部分
/**
* 滑动删除
*/
import React from "react";
import "./index.less";
class SlideDelete extends React.Component {
constructor(props) {
super(props);
this.state = {
width:0,
isShow:false
};
}
componentDidMount() {}
handleTouchStart = e => {
this.startX = e.touches[0].pageX;
this.startY = e.touches[0].pageY;
}
handleTouchMove = e => {
// 若想阻止冒泡且最外层盒子为scrollView,不可用e.stopPropogagation(),否则页面卡死
this.currentX = e.touches[0].pageX;
this.moveX = this.currentX - this.startX;
this.moveY = e.touches[0].pageY - this.startY;
// 纵向移动时return
if (Math.abs(this.moveY) > Math.abs(this.moveX)) {
return;
}
// 滑动超过一定距离时,才触发
if (Math.abs(this.moveX) < 10) {
return;