-
Notifications
You must be signed in to change notification settings - Fork 0
/
610-b5498121ebbef65cfdea.js.map
1 lines (1 loc) · 3.31 KB
/
610-b5498121ebbef65cfdea.js.map
1
{"version":3,"file":"610-b5498121ebbef65cfdea.js","mappings":"iLAGA,IAAIA,EAIEC,EAAa,IAAIC,QAEjBC,EACHC,UAAkBD,YAClBC,UAAkBC,eAClBD,UAAkBE,iBAAAA,SAQLC,EACdC,GAKA,MAAM,yBAA0BC,QAO3BT,IACHA,EAAuB,IAAIU,sBACzB,YACEC,EAAQC,SAAQ,kBACVC,EAAMC,iBAAAA,OAAAA,EAERb,EAAWc,IAAIF,EAAMG,UAAAA,IAErBf,EAAAA,OAAkBY,EAAMG,cAI9B,CACEC,WAAW,QAAXA,MAvBiBd,OAAAA,EAAAA,EAAYe,gBAAAA,MAwBCf,GAAAA,EAAYgB,SAAAA,SAAAA,YAAAA,SAQ9CC,GAQA,OANIA,EAAQC,UAEVpB,EAAWqB,IAAIF,EAAQC,QAASb,GAChCR,EAAqBuB,QAAQH,EAAQC,UAAAA,WAIjCrB,GAAwBoB,EAAQC,UAClCpB,EAAAA,OAAkBmB,EAAQC,SAC1BrB,EAAqBwB,UAAUJ,EAAQC,aAAAA,WArCzC,OADAb,IAAAA","sources":["webpack://team3602-com/../src/components/intersection-observer.ts"],"sourcesContent":["/* eslint-disable no-unused-expressions */\nimport { RefObject } from \"react\"\n\nlet intersectionObserver: IntersectionObserver\n\nexport type Unobserver = () => void\n\nconst ioEntryMap = new WeakMap<HTMLElement, () => void>()\n/* eslint-disable @typescript-eslint/no-explicit-any */\nconst connection =\n (navigator as any).connection ||\n (navigator as any).mozConnection ||\n (navigator as any).webkitConnection\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n// These match the thresholds used in Chrome's native lazy loading\n// @see https://web.dev/browser-level-image-lazy-loading/#distance-from-viewport-thresholds\nconst FAST_CONNECTION_THRESHOLD = `1250px`\nconst SLOW_CONNECTION_THRESHOLD = `2500px`\n\nexport function createIntersectionObserver(\n callback: () => void\n): (element: RefObject<HTMLElement | undefined>) => Unobserver {\n const connectionType = connection?.effectiveType\n\n // if we don't support intersectionObserver we don't lazy load (Sorry IE 11).\n if (!(`IntersectionObserver` in window)) {\n return function observe(): Unobserver {\n callback()\n return function unobserve(): void {}\n }\n }\n\n if (!intersectionObserver) {\n intersectionObserver = new IntersectionObserver(\n entries => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n // Get the matching entry's callback and call it\n ioEntryMap.get(entry.target as HTMLElement)?.()\n // We only need to call it once\n ioEntryMap.delete(entry.target as HTMLElement)\n }\n })\n },\n {\n rootMargin:\n connectionType === `4g` && !connection?.saveData\n ? FAST_CONNECTION_THRESHOLD\n : SLOW_CONNECTION_THRESHOLD,\n }\n )\n }\n\n return function observe(\n element: RefObject<HTMLElement | undefined>\n ): Unobserver {\n if (element.current) {\n // Store a reference to the callback mapped to the element being watched\n ioEntryMap.set(element.current, callback)\n intersectionObserver.observe(element.current)\n }\n\n return function unobserve(): void {\n if (intersectionObserver && element.current) {\n ioEntryMap.delete(element.current)\n intersectionObserver.unobserve(element.current)\n }\n }\n }\n}\n"],"names":["intersectionObserver","ioEntryMap","WeakMap","connection","navigator","mozConnection","webkitConnection","createIntersectionObserver","callback","window","IntersectionObserver","entries","forEach","entry","isIntersecting","get","target","rootMargin","effectiveType","saveData","element","current","set","observe","unobserve"],"sourceRoot":""}