'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

require('../../../../utils/index.cjs');
var isFirefox = require('../utils/isFirefox.cjs');
var useOriginScroll = require('./useOriginScroll.cjs');
var raf = require('../../../../utils/vue/raf.cjs');

function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta) {
  let offsetRef = 0;
  let nextFrame = null;
  let wheelValue = null;
  let isMouseScroll = false;
  const originScroll = useOriginScroll.default(isScrollAtTop, isScrollAtBottom);
  function onWheel(event) {
    if (!inVirtual.value)
      return;
    raf.raf.cancel(nextFrame);
    const { deltaY } = event;
    offsetRef += deltaY;
    wheelValue = deltaY;
    if (originScroll(deltaY))
      return;
    if (!isFirefox.default)
      event.preventDefault();
    nextFrame = raf.raf(() => {
      const patchMultiple = isMouseScroll ? 10 : 1;
      onWheelDelta(offsetRef * patchMultiple);
      offsetRef = 0;
    });
  }
  function onFireFoxScroll(event) {
    if (!inVirtual.value)
      return;
    isMouseScroll = event.detail === wheelValue;
  }
  return [onWheel, onFireFoxScroll];
}

exports.default = useFrameWheel;
//# sourceMappingURL=useFrameWheel.cjs.map
