"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useEventWheel = exports.useEventTouch = exports.useEventMouse = exports.useEventMonitor = exports.useEventKey = exports.useEventFocus = void 0;

var _handle = require("@enact/core/handle");

var _snapshot = require("@enact/core/snapshot");

var _util = require("@enact/core/util");

var _spotlight = _interopRequireWildcard(require("@enact/spotlight"));

var _utils = require("@enact/spotlight/src/utils");

var _useScroll = require("@enact/ui/useScroll");

var _utilEvent = _interopRequireDefault(require("@enact/ui/useScroll/utilEvent"));

var _utilDOM = _interopRequireDefault(require("@enact/ui/useScroll/utilDOM"));

var _react = require("react");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

var animationDuration = _useScroll.constants.animationDuration,
    epsilon = _useScroll.constants.epsilon,
    isPageDown = _useScroll.constants.isPageDown,
    isPageUp = _useScroll.constants.isPageUp,
    paginationPageMultiplier = _useScroll.constants.paginationPageMultiplier,
    scrollWheelPageMultiplierForMaxPixel = _useScroll.constants.scrollWheelPageMultiplierForMaxPixel;
var lastPointer = {
  x: 0,
  y: 0
};

var useEventFocus = function useEventFocus(props, instances, context) {
  var scrollMode = props.scrollMode;
  var scrollContainerHandle = instances.scrollContainerHandle,
      scrollContainerRef = instances.scrollContainerRef,
      scrollContentRef = instances.scrollContentRef,
      spottable = instances.spottable,
      themeScrollContentHandle = instances.themeScrollContentHandle;
  var alertScrollbarTrack = context.alertScrollbarTrack; // Functions

  var startScrollOnFocus = function startScrollOnFocus(pos) {
    if (pos) {
      var top = pos.top,
          left = pos.left,
          bounds = scrollContainerHandle.current.getScrollBounds();

      if (scrollMode === 'translate') {
        var scrollHorizontally = bounds.maxLeft > 0 && left !== scrollContainerHandle.current.scrollLeft,
            scrollVertically = bounds.maxTop > 0 && top !== scrollContainerHandle.current.scrollTop;

        if (scrollHorizontally || scrollVertically) {
          scrollContainerHandle.current.start({
            targetX: left,
            targetY: top,
            animate: animationDuration > 0 && spottable.current.animateOnFocus
          });
          spottable.current.lastScrollPositionOnFocus = pos;
        }
      } else {
        var _scrollHorizontally = bounds.maxLeft > 0 && Math.abs(left - scrollContainerHandle.current.scrollLeft) > epsilon,
            _scrollVertically = bounds.maxTop > 0 && Math.abs(top - scrollContainerHandle.current.scrollTop) > epsilon;

        if (_scrollHorizontally || _scrollVertically) {
          scrollContainerHandle.current.start({
            targetX: left,
            targetY: top,
            animate: spottable.current.animateOnFocus
          });
          spottable.current.lastScrollPositionOnFocus = pos;
        }
      }
    }
  };

  function calculateAndScrollTo() {
    var positionFn = themeScrollContentHandle.current.calculatePositionOnFocus,
        scrollContentNode = scrollContentRef.current,
        spotItem = _spotlight["default"].getCurrent();

    if (spotItem && positionFn && _utilDOM["default"].containsDangerously(scrollContentNode, spotItem)) {
      var lastPos = spottable.current.lastScrollPositionOnFocus;
      var pos; // If scroll animation is ongoing, we need to pass last target position to
      // determine correct scroll position.

      if (lastPos & (scrollMode === 'translate' && scrollContainerHandle.current.animator.isAnimating() || scrollMode === 'native' && scrollContainerHandle.current.scrolling)) {
        var contentRect = (0, _utils.getRect)(scrollContentNode),
            itemRect = (0, _utils.getRect)(spotItem);
        var scrollPosition;

        if (props.direction === 'horizontal' || props.direction === 'both' && !(itemRect.left >= contentRect.left && itemRect.right <= contentRect.right)) {
          scrollPosition = lastPos.left;
        } else if (props.direction === 'vertical' || props.direction === 'both' && !(itemRect.top >= contentRect.top && itemRect.bottom <= contentRect.bottom)) {
          scrollPosition = lastPos.top;
        }

        pos = positionFn({
          item: spotItem,
          scrollPosition: scrollPosition
        });
      } else {
        pos = positionFn({
          item: spotItem
        });
      }

      if (pos && (pos.left !== scrollContainerHandle.current.scrollLeft || pos.top !== scrollContainerHandle.current.scrollTop)) {
        startScrollOnFocus(pos);
      } // update `scrollHeight`


      scrollContainerHandle.current.bounds.scrollHeight = scrollContainerHandle.current.getScrollBounds().scrollHeight;
    }
  }

  function handleFocus(ev) {
    var shouldPreventScrollByFocus = themeScrollContentHandle.current.shouldPreventScrollByFocus ? themeScrollContentHandle.current.shouldPreventScrollByFocus() : false;

    if (spottable.current.isWheeling) {
      scrollContainerHandle.current.stop();

      if (scrollMode === 'translate') {
        spottable.current.animateOnFocus = false;
      }
    }

    if (!_spotlight["default"].getPointerMode()) {
      alertScrollbarTrack();
    }

    if (!(shouldPreventScrollByFocus || _spotlight["default"].getPointerMode() || scrollContainerHandle.current.isDragging || spottable.current.indexToFocus)) {
      var item = ev.target,
          spotItem = _spotlight["default"].getCurrent();

      if (item && item === spotItem) {
        calculateAndScrollTo();
      }
    } else if (themeScrollContentHandle.current.setLastFocusedNode) {
      themeScrollContentHandle.current.setLastFocusedNode(ev.target);
    }
  }

  function hasFocus() {
    var current = _spotlight["default"].getCurrent();

    if (current && scrollContainerRef.current) {
      return _utilDOM["default"].containsDangerously(scrollContainerRef, current);
    }
  } // Return


  return {
    calculateAndScrollTo: calculateAndScrollTo,
    handleFocus: handleFocus,
    hasFocus: hasFocus
  };
};

exports.useEventFocus = useEventFocus;

var useEventKey = function useEventKey(props, instances, context) {
  var scrollMode = props.scrollMode;
  var themeScrollContentHandle = instances.themeScrollContentHandle,
      spottable = instances.spottable,
      scrollContentRef = instances.scrollContentRef,
      scrollContainerHandle = instances.scrollContainerHandle;
  var hasFocus = context.hasFocus,
      isContent = context.isContent; // Functions

  function handleKeyDown(ev) {
    var keyCode = ev.keyCode,
        repeat = ev.repeat,
        target = ev.target;
    (0, _handle.forward)('onKeyDown', ev, props);

    if (isPageUp(keyCode) || isPageDown(keyCode)) {
      ev.preventDefault();
    }

    spottable.current.animateOnFocus = true;

    if (!repeat && hasFocus()) {
      var direction = null;

      if (isPageUp(keyCode) || isPageDown(keyCode)) {
        if (props.direction === 'vertical' || props.direction === 'both') {
          direction = isPageUp(keyCode) ? 'up' : 'down';

          if (isContent(target)) {
            ev.stopPropagation();
            scrollByPage(direction);
          }
        }
      } else if ((0, _spotlight.getDirection)(keyCode) && (scrollMode === 'translate' || scrollMode === 'native' && !_spotlight["default"].getPointerMode())) {
        scrollContainerHandle.current.lastInputType = 'arrowKey';
        direction = (0, _spotlight.getDirection)(keyCode);
      }
    }
  }

  function scrollByPage(direction) {
    var scrollTop = scrollContainerHandle.current.scrollTop,
        focusedItem = _spotlight["default"].getCurrent(),
        bounds = scrollContainerHandle.current.getScrollBounds(),
        isUp = direction === 'up',
        directionFactor = isUp ? -1 : 1,
        pageDistance = directionFactor * bounds.clientHeight * paginationPageMultiplier;

    var scrollPossible = false;

    if (scrollMode === 'translate') {
      scrollPossible = isUp ? scrollTop > 0 : bounds.maxTop > scrollTop;
    } else {
      scrollPossible = isUp ? scrollTop > 0 : bounds.maxTop - scrollTop > epsilon;
    }

    scrollContainerHandle.current.lastInputType = 'pageKey';

    if (directionFactor !== scrollContainerHandle.current.wheelDirection) {
      scrollContainerHandle.current.isScrollAnimationTargetAccumulated = false;
      scrollContainerHandle.current.wheelDirection = directionFactor;
    }

    if (scrollPossible) {
      if (focusedItem) {
        var contentNode = scrollContentRef.current; // Should do nothing when focusedItem is paging control button of Scrollbar

        if (_utilDOM["default"].containsDangerously(contentNode, focusedItem)) {
          var contentRect = contentNode.getBoundingClientRect(),
              clientRect = focusedItem.getBoundingClientRect(),
              yAdjust = isUp ? 1 : -1,
              x = (0, _util.clamp)(contentRect.left, contentRect.right, (clientRect.right + clientRect.left) / 2);
          var y = 0;

          if (scrollMode === 'translate') {
            y = bounds.maxTop <= scrollTop + pageDistance || 0 >= scrollTop + pageDistance ? contentRect[isUp ? 'top' : 'bottom'] + yAdjust : (0, _util.clamp)(contentRect.top, contentRect.bottom, (clientRect.bottom + clientRect.top) / 2);
          } else {
            y = bounds.maxTop - epsilon < scrollTop + pageDistance || epsilon > scrollTop + pageDistance ? contentNode.getBoundingClientRect()[isUp ? 'top' : 'bottom'] + yAdjust : (0, _util.clamp)(contentRect.top, contentRect.bottom, (clientRect.bottom + clientRect.top) / 2);
          }

          focusedItem.blur();

          if (!props['data-spotlight-container-disabled']) {
            themeScrollContentHandle.current.setContainerDisabled(true);
          }

          if (themeScrollContentHandle.current.pauseSpotlight) {
            themeScrollContentHandle.current.pauseSpotlight(true);
          }

          spottable.current.pointToFocus = {
            direction: direction,
            x: x,
            y: y
          };
        }
      } else {
        spottable.current.pointToFocus = {
          direction: direction,
          x: lastPointer.x,
          y: lastPointer.y
        };
      }

      scrollContainerHandle.current.scrollToAccumulatedTarget(pageDistance, true);
    }
  }

  function scrollByPageOnPointerMode(ev) {
    var keyCode = ev.keyCode,
        repeat = ev.repeat;
    (0, _handle.forward)('onKeyDown', ev, props);
    ev.preventDefault();
    spottable.current.animateOnFocus = true;

    if (!repeat && (props.direction === 'vertical' || props.direction === 'both')) {
      var direction = isPageUp(keyCode) ? 'up' : 'down';
      scrollByPage(direction);
      return true; // means consumed
    }

    return false; // means to be propagated
  } // Return


  return {
    handleKeyDown: handleKeyDown,
    lastPointer: lastPointer,
    scrollByPageOnPointerMode: scrollByPageOnPointerMode
  };
};
/*
 * Track the last position of the pointer to check if a list should scroll by
 * page up/down keys when the pointer is on a list without any focused node.
 * `keydown` event does not occur if there is no focus on the node and
 * its descendants, we add `keydown` handler to `document` also.
 */


exports.useEventKey = useEventKey;
var scrollers = new Map(); // An app could have lists and/or scrollers more than one,
// so we should test all of them when page up/down key is pressed.

var pointerTracker = function pointerTracker(ev) {
  lastPointer.x = ev.clientX;
  lastPointer.y = ev.clientY;
};

var pageKeyHandler = function pageKeyHandler(ev) {
  var keyCode = ev.keyCode;

  if (_spotlight["default"].getPointerMode() && !_spotlight["default"].getCurrent() && (isPageUp(keyCode) || isPageDown(keyCode))) {
    var _lastPointer = lastPointer,
        x = _lastPointer.x,
        y = _lastPointer.y,
        elem = document.elementFromPoint(x, y);

    if (elem) {
      var _iterator = _createForOfIteratorHelper(scrollers),
          _step;

      try {
        for (_iterator.s(); !(_step = _iterator.n()).done;) {
          var _step$value = _slicedToArray(_step.value, 2),
              key = _step$value[0],
              value = _step$value[1];

          if (_utilDOM["default"].containsDangerously(value, elem)) {
            /* To handle page keys in nested scrollable components,
             * break the loop only when `scrollByPageOnPointerMode` returns `true`.
             * This approach assumes that an inner scrollable component is
             * mounted earlier than an outer scrollable component.
             */
            if (key.scrollByPageOnPointerMode(ev)) {
              break;
            }
          }
        }
      } catch (err) {
        _iterator.e(err);
      } finally {
        _iterator.f();
      }
    }
  }
};

var useEventMonitor = function useEventMonitor(props, instances, context) {
  var scrollContainerRef = instances.scrollContainerRef;
  var lastPointerProp = context.lastPointer,
      scrollByPageOnPointerMode = context.scrollByPageOnPointerMode; // Mutable value

  var mutableRef = (0, _react.useRef)({
    pageKeyHandlerObj: {
      scrollByPageOnPointerMode: scrollByPageOnPointerMode
    }
  });
  lastPointer = lastPointerProp; // Hooks

  (0, _react.useEffect)(function () {
    var setMonitorEventTarget = function setMonitorEventTarget(target) {
      scrollers.set(mutableRef.current.pageKeyHandlerObj, target);
    };

    var deleteMonitorEventTarget = function deleteMonitorEventTarget() {
      scrollers["delete"](mutableRef.current.pageKeyHandlerObj);
    };

    setMonitorEventTarget(scrollContainerRef.current);
    return function () {
      // TODO: Replace `this` to something.
      deleteMonitorEventTarget();
    };
  }, [scrollContainerRef]);
};

exports.useEventMonitor = useEventMonitor;
(0, _snapshot.onWindowReady)(function () {
  (0, _utilEvent["default"])('mousemove').addEventListener(document, pointerTracker);
  (0, _utilEvent["default"])('keydown').addEventListener(document, pageKeyHandler);
});

var useEventMouse = function useEventMouse(props, instances, context) {
  var scrollMode = props.scrollMode;
  var themeScrollContentHandle = instances.themeScrollContentHandle,
      scrollContainerHandle = instances.scrollContainerHandle;
  var isScrollButtonFocused = context.isScrollButtonFocused; // Functions

  function handleDragEnd() {
    scrollContainerHandle.current.isDragging = false;

    if (!scrollContainerHandle.current.isFlicked) {
      themeScrollContentHandle.current.setContainerDisabled(false);
    }
  }

  function handleDragStart() {
    scrollContainerHandle.current.isDragging = true;
    themeScrollContentHandle.current.setContainerDisabled(true);
  }

  function handleFlick(_ref) {
    var direction = _ref.direction;

    var _scrollContainerHandl = scrollContainerHandle.current,
        canScrollHorizontally = _scrollContainerHandl.canScrollHorizontally,
        canScrollVertically = _scrollContainerHandl.canScrollVertically,
        bounds = scrollContainerHandle.current.getScrollBounds(),
        focusedItem = _spotlight["default"].getCurrent();

    scrollContainerHandle.current.isFlicked = true;

    if (focusedItem) {
      focusedItem.blur();
    }

    if ((direction === 'vertical' && canScrollVertically(bounds) || direction === 'horizontal' && canScrollHorizontally(bounds)) && !props['data-spotlight-container-disabled']) {
      themeScrollContentHandle.current.setContainerDisabled(true);
    }
  }

  function handleMouseDown(ev) {
    if (isScrollButtonFocused()) {
      ev.preventDefault();
    }

    if (props['data-spotlight-container-disabled']) {
      ev.preventDefault();
    } else if (scrollMode === 'native') {
      themeScrollContentHandle.current.setContainerDisabled(false);
    }
  } // Return


  return {
    handleDragEnd: handleDragEnd,
    handleDragStart: handleDragStart,
    handleFlick: handleFlick,
    handleMouseDown: handleMouseDown
  };
};

exports.useEventMouse = useEventMouse;

var useEventTouch = function useEventTouch(props, instnaces, context) {
  var isScrollButtonFocused = context.isScrollButtonFocused; // Functions

  function handleTouchStart() {
    var focusedItem = _spotlight["default"].getCurrent();

    if (!_spotlight["default"].isPaused() && focusedItem && !isScrollButtonFocused()) {
      focusedItem.blur();
    }
  } // Return


  return {
    handleTouchStart: handleTouchStart
  };
};

exports.useEventTouch = useEventTouch;

var useEventWheel = function useEventWheel(props, instances, context) {
  var scrollMode = props.scrollMode;
  var themeScrollContentHandle = instances.themeScrollContentHandle,
      horizontalScrollbarHandle = instances.horizontalScrollbarHandle,
      scrollContainerHandle = instances.scrollContainerHandle,
      verticalScrollbarHandle = instances.verticalScrollbarHandle,
      spottable = instances.spottable;
  var isScrollButtonFocused = context.isScrollButtonFocused; // Functions

  function handleWheel(_ref2) {
    var delta = _ref2.delta;

    var focusedItem = _spotlight["default"].getCurrent();

    if (focusedItem && !isScrollButtonFocused()) {
      focusedItem.blur();
    }

    if (delta !== 0) {
      spottable.current.isWheeling = true;

      if (!props['data-spotlight-container-disabled']) {
        themeScrollContentHandle.current.setContainerDisabled(true);
      }
    }
  }
  /*
   * wheel event handler;
   * - for horizontal scroll, supports wheel action on any children nodes since web engine cannot support this
   * - for vertical scroll, supports wheel action on scrollbars only
   */


  function handleWheelNative(ev) {
    var bounds = scrollContainerHandle.current.getScrollBounds(),
        canScrollHorizontally = scrollContainerHandle.current.canScrollHorizontally(bounds),
        canScrollVertically = scrollContainerHandle.current.canScrollVertically(bounds),
        eventDeltaMode = ev.deltaMode,
        eventDelta = -ev.wheelDeltaY || ev.deltaY;
    var delta = 0,
        needToHideScrollbarTrack = false;

    if (typeof window !== 'undefined') {
      window.document.activeElement.blur();
    }

    scrollContainerHandle.current.showScrollbarTrack(bounds); // FIXME This routine is a temporary support for horizontal wheel scroll.
    // FIXME If web engine supports horizontal wheel, this routine should be refined or removed.

    if (canScrollVertically) {
      // This routine handles wheel events on scrollbars for vertical scroll.
      if (eventDelta < 0 && scrollContainerHandle.current.scrollTop > 0 || eventDelta > 0 && scrollContainerHandle.current.scrollTop < bounds.maxTop) {
        if (!spottable.current.isWheeling) {
          if (!props['data-spotlight-container-disabled']) {
            themeScrollContentHandle.current.setContainerDisabled(true);
          }

          spottable.current.isWheeling = true;
        } // Not to check if ev.target is a descendant of a wrapped component which may have a lot of nodes in it.


        if (horizontalScrollbarHandle.current && _utilDOM["default"].containsDangerously(horizontalScrollbarHandle.current.getContainerRef(), ev.target) || verticalScrollbarHandle.current && _utilDOM["default"].containsDangerously(verticalScrollbarHandle.current.getContainerRef(), ev.target)) {
          delta = scrollContainerHandle.current.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientHeight * scrollWheelPageMultiplierForMaxPixel);
          needToHideScrollbarTrack = !delta;
          ev.preventDefault();
        }

        ev.stopPropagation();
      } else {
        needToHideScrollbarTrack = true;
      }
    } else if (canScrollHorizontally) {
      // this routine handles wheel events on any children for horizontal scroll.
      if (eventDelta < 0 && scrollContainerHandle.current.scrollLeft > 0 || eventDelta > 0 && scrollContainerHandle.current.scrollLeft < bounds.maxLeft) {
        if (!spottable.current.isWheeling) {
          if (!props['data-spotlight-container-disabled']) {
            themeScrollContentHandle.current.setContainerDisabled(true);
          }

          spottable.current.isWheeling = true;
        }

        delta = scrollContainerHandle.current.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientWidth * scrollWheelPageMultiplierForMaxPixel);
        needToHideScrollbarTrack = !delta;
        ev.preventDefault();
        ev.stopPropagation();
      } else {
        needToHideScrollbarTrack = true;
      }
    }

    if (delta !== 0) {
      /* prevent native scrolling feature for vertical direction */
      ev.preventDefault();
      var direction = Math.sign(delta); // Not to accumulate scroll position if wheel direction is different from hold direction

      if (direction !== scrollContainerHandle.current.wheelDirection) {
        scrollContainerHandle.current.isScrollAnimationTargetAccumulated = false;
        scrollContainerHandle.current.wheelDirection = direction;
      }

      scrollContainerHandle.current.scrollToAccumulatedTarget(delta, canScrollVertically);
    }

    if (needToHideScrollbarTrack) {
      scrollContainerHandle.current.startHidingScrollbarTrack();
    }
  } // Return


  return {
    handleWheel: scrollMode === 'translate' ? handleWheel : handleWheelNative
  };
};

exports.useEventWheel = useEventWheel;