import '../../../../utils/index.mjs';
import isFF from '../utils/isFirefox.mjs';
import useOriginScroll from './useOriginScroll.mjs';
import { raf } from '../../../../utils/vue/raf.mjs';

function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta) {
  let offsetRef = 0;
  let nextFrame = null;
  let wheelValue = null;
  let isMouseScroll = false;
  const originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
  function onWheel(event) {
    if (!inVirtual.value)
      return;
    raf.cancel(nextFrame);
    const { deltaY } = event;
    offsetRef += deltaY;
    wheelValue = deltaY;
    if (originScroll(deltaY))
      return;
    if (!isFF)
      event.preventDefault();
    nextFrame = 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];
}

export { useFrameWheel as default };
//# sourceMappingURL=useFrameWheel.mjs.map
