"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeWheelListener = makeWheelListener;
exports.listenWheel = listenWheel;
function makeWheelListener(listener) {
    return (component) => {
        return listenWheel(component, (event, _event) => {
            listener(event, _event);
        });
    };
}
function listenWheel(component, onWheel) {
    const { $system: { api: { document: { elementFromPoint }, }, }, $element, } = component;
    const wheelListener = (_event) => {
        const { $context, $element } = component;
        const { $x, $y, $sx, $sy } = $context;
        const { deltaX, deltaY, ctrlKey, altKey, clientX, clientY, offsetX, offsetY, } = _event;
        if (ctrlKey) {
            return;
        }
        const { scrollLeft, scrollTop } = _event.target;
        onWheel({
            deltaY,
            deltaX,
            ctrlKey,
            altKey,
            clientX: (clientX - $x) / $sx,
            clientY: (clientY - $y) / $sy,
            offsetX,
            offsetY,
            screenX: clientX,
            screenY: clientY,
            scrollLeft,
            scrollTop,
        }, _event);
    };
    // $element.addEventListener('wheel', wheelListener, { passive: true })
    $element.addEventListener('wheel', wheelListener, { passive: false });
    return () => {
        $element.removeEventListener('wheel', wheelListener);
    };
}
//# sourceMappingURL=wheel.js.map