"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeTouchMoveListener = makeTouchMoveListener;
exports.listenTouchMove = listenTouchMove;
function makeTouchMoveListener(listener) {
    return (component) => {
        return listenTouchMove(component, listener);
    };
}
function listenTouchMove(component, listener) {
    const { $element } = component;
    const touchMoveListener = (_event) => {
        const { $context } = component;
        // log('touchmove')
        const { $x, $y, $sx, $sy } = $context;
        const { changedTouches, touches } = _event;
        const event = [];
        for (let i = 0; i < touches.length; i++) {
            const touch = touches[i];
            const { clientX, clientY } = touch;
            event.push({
                clientX: (clientX - $x) / $sx,
                clientY: (clientY - $y) / $sy,
                screenX: clientX,
                screenY: clientY,
            });
        }
        listener(event, _event);
    };
    $element.addEventListener('touchmove', touchMoveListener);
    return () => {
        $element.removeEventListener('touchmove', touchMoveListener);
    };
}
//# sourceMappingURL=touchmove.js.map