"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.usePreventScroll = exports["default"] = void 0;
var _utilEvent = _interopRequireDefault(require("@enact/ui/useScroll/utilEvent"));
var _react = require("react");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var usePreventScroll = exports.usePreventScroll = function usePreventScroll(props, instances) {
  // Hooks

  (0, _react.useEffect)(function () {
    var rtl = props.rtl,
      scrollMode = props.scrollMode;
    var scrollContentRef = instances.scrollContentRef;
    var scrollContentNode = scrollContentRef.current;
    if (scrollMode === 'translate' && scrollContentNode) {
      var preventScroll = function preventScroll() {
        scrollContentNode.scrollTop = 0;
        scrollContentNode.scrollLeft = rtl ? scrollContentNode.scrollWidth : 0;
      };
      (0, _utilEvent["default"])('scroll').addEventListener(scrollContentNode, preventScroll);
      return function () {
        // remove a function for preventing native scrolling by Spotlight
        (0, _utilEvent["default"])('scroll').removeEventListener(scrollContentNode, preventScroll);
      };
    }
  }, [props, instances]);
};
var _default = exports["default"] = usePreventScroll;