"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
/**
 * Copyright (c) JOB TODAY S.A. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */
// @ts-nocheck

const useImageIndexChange = (imageIndex, screen) => {
  const [currentImageIndex, setImageIndex] = (0, _react.useState)(imageIndex);
  const onScroll = event => {
    const {
      nativeEvent: {
        contentOffset: {
          x: scrollX
        }
      }
    } = event;
    if (screen.width) {
      const nextIndex = Math.round(scrollX / screen.width);
      setImageIndex(nextIndex < 0 ? 0 : nextIndex);
    }
  };
  return [currentImageIndex, onScroll];
};
var _default = useImageIndexChange;
exports.default = _default;
//# sourceMappingURL=useImageIndexChange.js.map