protected bindTouchEvents()

in share/src/components/Joystick.tsx [173:216]


    protected bindTouchEvents(div: HTMLDivElement) {
        let touchIdentifier: number | undefined;

        div.addEventListener("touchend", ev => {
            if (touchIdentifier) {
                const touch = getTouch(ev, touchIdentifier);

                if (touch) {
                    this.updateJoystickDrag(touch.clientX, touch.clientY);
                    this.startAnimation();
                    ev.preventDefault();
                }
            }
            touchIdentifier = undefined;
        });

        div.addEventListener("touchstart", ev => {
            touchIdentifier = ev.changedTouches[0].identifier;
            this.updateJoystickDrag(ev.changedTouches[0].clientX, ev.changedTouches[0].clientY);
        });

        div.addEventListener("touchmove", ev => {
            if (touchIdentifier) {
                const touch = getTouch(ev, touchIdentifier);

                if (touch) {
                    this.updateJoystickDrag(touch.clientX, touch.clientY);
                    ev.preventDefault();
                }
            }
        });

        div.addEventListener("touchcancel", ev => {
            if (touchIdentifier) {
                const touch = getTouch(ev, touchIdentifier);

                if (touch) {
                    this.updateJoystickDrag(touch.clientX, touch.clientY);
                    this.startAnimation();
                }
            }
            touchIdentifier = undefined;
        });
    }