{"version":3,"file":"in-view.a07afd0f.js","sources":["../../node_modules/@motionone/dom/dist/gestures/in-view.es.js"],"sourcesContent":["import { resolveElements } from '../utils/resolve-elements.es.js';\nimport { isFunction } from '@motionone/utils';\n\nconst thresholds = {\n any: 0,\n all: 1,\n};\nfunction inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = \"any\" } = {}) {\n /**\n * If this browser doesn't support IntersectionObserver, return a dummy stop function.\n * Default triggering of onStart is tricky - it could be used for starting/stopping\n * videos, lazy loading content etc. We could provide an option to enable a fallback, or\n * provide a fallback callback option.\n */\n if (typeof IntersectionObserver === \"undefined\") {\n return () => { };\n }\n const elements = resolveElements(elementOrSelector);\n const activeIntersections = new WeakMap();\n const onIntersectionChange = (entries) => {\n entries.forEach((entry) => {\n const onEnd = activeIntersections.get(entry.target);\n /**\n * If there's no change to the intersection, we don't need to\n * do anything here.\n */\n if (entry.isIntersecting === Boolean(onEnd))\n return;\n if (entry.isIntersecting) {\n const newOnEnd = onStart(entry);\n if (isFunction(newOnEnd)) {\n activeIntersections.set(entry.target, newOnEnd);\n }\n else {\n observer.unobserve(entry.target);\n }\n }\n else if (onEnd) {\n onEnd(entry);\n activeIntersections.delete(entry.target);\n }\n });\n };\n const observer = new IntersectionObserver(onIntersectionChange, {\n root,\n rootMargin,\n threshold: typeof amount === \"number\" ? amount : thresholds[amount],\n });\n elements.forEach((element) => observer.observe(element));\n return () => observer.disconnect();\n}\n\nexport { inView };\n"],"names":["thresholds","inView","elementOrSelector","onStart","root","rootMargin","amount","elements","resolveElements","activeIntersections","onIntersectionChange","entries","entry","onEnd","newOnEnd","isFunction","observer","element"],"mappings":"0DAGA,MAAMA,EAAa,CACf,IAAK,EACL,IAAK,CACT,EACA,SAASC,EAAOC,EAAmBC,EAAS,CAAE,KAAAC,EAAM,OAAQC,EAAY,OAAAC,EAAS,KAAO,EAAG,GAAI,CAO3F,GAAI,OAAO,qBAAyB,IAChC,MAAO,IAAM,CAAA,EAEjB,MAAMC,EAAWC,EAAgBN,CAAiB,EAC5CO,EAAsB,IAAI,QAC1BC,EAAwBC,GAAY,CACtCA,EAAQ,QAASC,GAAU,CACvB,MAAMC,EAAQJ,EAAoB,IAAIG,EAAM,MAAM,EAKlD,GAAIA,EAAM,iBAAmB,QAAQC,CAAK,EAE1C,GAAID,EAAM,eAAgB,CACtB,MAAME,EAAWX,EAAQS,CAAK,EAC1BG,EAAWD,CAAQ,EACnBL,EAAoB,IAAIG,EAAM,OAAQE,CAAQ,EAG9CE,EAAS,UAAUJ,EAAM,MAAM,CAEtC,MACQC,IACLA,EAAMD,CAAK,EACXH,EAAoB,OAAOG,EAAM,MAAM,EAEvD,CAAS,CACT,EACUI,EAAW,IAAI,qBAAqBN,EAAsB,CAC5D,KAAAN,EACA,WAAAC,EACA,UAAW,OAAOC,GAAW,SAAWA,EAASN,EAAWM,CAAM,CAC1E,CAAK,EACD,OAAAC,EAAS,QAASU,GAAYD,EAAS,QAAQC,CAAO,CAAC,EAChD,IAAMD,EAAS,YAC1B"}