"use strict";

exports.__esModule = true;
exports.useHorizontalSwipe = void 0;
var _react = require("react");
var useHorizontalSwipe = _ref => {
  var {
    onSwipe,
    threshold = 50,
    disabled = false
  } = _ref;
  var touchStart = (0, _react.useRef)({
    x: 0,
    y: 0
  });
  var handleTouchStart = event => {
    if (disabled) return;
    var touch = event.touches[0];
    touchStart.current = {
      x: touch.clientX,
      y: touch.clientY
    };
  };
  var handleTouchEnd = event => {
    if (disabled) return;
    var touch = event.changedTouches[0];
    var deltaX = Math.abs(touch.clientX - touchStart.current.x);
    var deltaY = Math.abs(touch.clientY - touchStart.current.y);
    if (deltaX > deltaY && deltaX >= threshold) {
      onSwipe == null || onSwipe();
    }
  };
  return {
    onTouchStart: handleTouchStart,
    onTouchEnd: handleTouchEnd
  };
};
exports.useHorizontalSwipe = useHorizontalSwipe;
//# sourceMappingURL=useHorizontalSwipe.js.map