0931e23509bf67f8e215fcbc96d97162.json
4.69 KB
{"ast":null,"code":"import { useRef } from 'react';\nimport raf from \"rc-util/es/raf\";\nimport isFF from '../utils/isFirefox';\nimport useOriginScroll from './useOriginScroll';\nexport default function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta) {\n var offsetRef = useRef(0);\n var nextFrameRef = useRef(null); // Firefox patch\n\n var wheelValueRef = useRef(null);\n var isMouseScrollRef = useRef(false); // Scroll status sync\n\n var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);\n\n function onWheel(event) {\n if (!inVirtual) return;\n raf.cancel(nextFrameRef.current);\n var deltaY = event.deltaY;\n offsetRef.current += deltaY;\n wheelValueRef.current = deltaY; // Do nothing when scroll at the edge, Skip check when is in scroll\n\n if (originScroll(deltaY)) return; // Proxy of scroll events\n\n if (!isFF) {\n event.preventDefault();\n }\n\n nextFrameRef.current = raf(function () {\n // Patch a multiple for Firefox to fix wheel number too small\n // ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266\n var patchMultiple = isMouseScrollRef.current ? 10 : 1;\n onWheelDelta(offsetRef.current * patchMultiple);\n offsetRef.current = 0;\n });\n } // A patch for firefox\n\n\n function onFireFoxScroll(event) {\n if (!inVirtual) return;\n isMouseScrollRef.current = event.detail === wheelValueRef.current;\n }\n\n return [onWheel, onFireFoxScroll];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js"],"names":["useRef","raf","isFF","useOriginScroll","useFrameWheel","inVirtual","isScrollAtTop","isScrollAtBottom","onWheelDelta","offsetRef","nextFrameRef","wheelValueRef","isMouseScrollRef","originScroll","onWheel","event","cancel","current","deltaY","preventDefault","patchMultiple","onFireFoxScroll","detail"],"mappings":"AAAA,SAASA,MAAT,QAAuB,OAAvB;AACA,OAAOC,GAAP,MAAgB,gBAAhB;AACA,OAAOC,IAAP,MAAiB,oBAAjB;AACA,OAAOC,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gBAAgB,CAACK,OAAjB,GAA2BF,KAAK,CAACO,MAAN,KAAiBX,aAAa,CAACM,OAA1D;AACD;;AAED,SAAO,CAACH,OAAD,EAAUO,eAAV,CAAP;AACD","sourcesContent":["import { useRef } from 'react';\nimport raf from \"rc-util/es/raf\";\nimport isFF from '../utils/isFirefox';\nimport useOriginScroll from './useOriginScroll';\nexport default function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta) {\n var offsetRef = useRef(0);\n var nextFrameRef = useRef(null); // Firefox patch\n\n var wheelValueRef = useRef(null);\n var isMouseScrollRef = useRef(false); // Scroll status sync\n\n var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);\n\n function onWheel(event) {\n if (!inVirtual) return;\n raf.cancel(nextFrameRef.current);\n var deltaY = event.deltaY;\n offsetRef.current += deltaY;\n wheelValueRef.current = deltaY; // Do nothing when scroll at the edge, Skip check when is in scroll\n\n if (originScroll(deltaY)) return; // Proxy of scroll events\n\n if (!isFF) {\n event.preventDefault();\n }\n\n nextFrameRef.current = raf(function () {\n // Patch a multiple for Firefox to fix wheel number too small\n // ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266\n var patchMultiple = isMouseScrollRef.current ? 10 : 1;\n onWheelDelta(offsetRef.current * patchMultiple);\n offsetRef.current = 0;\n });\n } // A patch for firefox\n\n\n function onFireFoxScroll(event) {\n if (!inVirtual) return;\n isMouseScrollRef.current = event.detail === wheelValueRef.current;\n }\n\n return [onWheel, onFireFoxScroll];\n}"]},"metadata":{},"sourceType":"module"}