tsx
import { Component } from "react";
import './index.less';
interface Props {
}
interface State {
Num: number,
MaxNum: number,
}
class Drag extends Component<Props, State>{
constructor(props: Props) {
super(props);
this.state = {
Num: 0,
MaxNum: 100
}
}
parent?: HTMLDivElement;
child!: HTMLCollection;
startX: number = 0;
ballW: number = 0;
oW: number = 0;
x: number = 0;
dis: number = 0;
Num: number = 0;
MaxNum: number = 0;
scale: number = 0;
FnStart(ev: React.TouchEvent) {
this.startX = ev.changedTouches[0].pageX - (ev.target as HTMLDivElement).offsetLeft;
this.parent = ((ev.target as HTMLDivElement).parentNode) as HTMLDivElement;
this.child = this.parent.children;
this.ballW = (ev.target as HTMLDivElement).offsetWidth;
this.oW = this.parent.offsetWidth - t