const MIN_TOUCH_DISTENCE = 50
handleTouchStart = (e) => {
this.startX = e.touches[0].clientX;
}
handleTouchMove = (e) => {
this.endX = e.touches[0].clientX;
console.log(e.touches[0])
}
handleTouchEnd = (e) => {
console.log(e.touches)
let distance = Math.abs(this.startX - this.endX);
if (distance > MIN_TOUCH_DISTENCE) {
if (this.startX > this.endX) {
this.refs.myul.style.marginLeft = -(this.state.x+ distance).toString()+"px"
this.setState({
x:this.state.x+distance
})
if(this.refs.myul.style.marginLeft>"0"){
this.refs.myul.style.marginLeft = "0px"
this.setState({
x:0
})
}
const width = - parseFloat(this.refs.myul.style.width)*100+200;
console.log(width)
if(parseFloat(this.refs.myul.style.marginLeft) < width){
this.setState({
x:this.state.x
})
this.refs.myul.style.marginLeft = width.toString()+"px"
}
var num =100;
} else {
this.setState({
x:this.state.x-distance
})
this.refs.myul.style.marginLeft =-this.state.x.toString()+"px"
if(this.refs.myul.style.marginLeft>"0"){
this.refs.myul.style.marginLeft = "0px"
}
}
}
}