{"version":3,"file":"2692.41977e26fbe43d2ac6ea.js","mappings":"mrCACA,IAAMA,EAAiBC,OAAOD,gBAAkBE,EAAAA,GAI5CC,EAAQC,SAASC,cAAc,QAC/BC,EAAK,EACLC,EAAK,EACLC,EAAM,EAGJC,EAAc,SAACC,EAAEC,GAChBD,GAAKH,GAAMI,GAAKL,GACfL,OAAOW,uBAAsB,YAEtBF,GAAKH,GAAOG,GAAKH,GAAMM,KAAKC,IAAIH,EAAIH,GAN1B,MAOTA,EAAMG,EACNP,SAASW,gBAAgBC,MAAMC,YAAY,oBAA3C,UAAmET,EAAnE,QAGDE,GAAKH,IACJA,EAAKG,EACLN,SAASW,gBAAgBC,MAAMC,YAAY,YAA3C,UAA2DV,EAA3D,QAGDI,GAAKL,IACJA,EAAKK,EACLP,SAASW,gBAAgBC,MAAMC,YAAY,aAA3C,UAA4DX,EAA5D,OAEP,GAER,EAIKY,EAAUd,SAASe,cAAc,OACvCD,EAAQE,aAAa,KAAK,YAC1BF,EAAQE,aAAa,cAAc,QACnCF,EAAQE,aAAa,QAAQ,+EAC7BjB,EAAMkB,YAAYH,GAIY,IAAIlB,GAAe,SAAAsB,GAAW,UACtCA,GADsC,IACxD,IAAK,EAAL,qBAA2B,KACjBC,EADiB,QACNC,YACjBf,EAAYc,EAAGE,MAAMF,EAAGG,OAC3B,CAJuD,+BAK3D,IAEqBC,QAAQT,E","sources":["webpack://nationalspacecentre.web/./wwwroot/app/src/js/viewport-size.js"],"sourcesContent":["import { ResizeObserver as Polyfill } from '@juggle/resize-observer';\r\nconst ResizeObserver = window.ResizeObserver || Polyfill;\r\n\r\n// add element to body for accurately reporting viewport size\r\n\r\nlet $body = document.querySelector('body'),\r\n vh = 0,\r\n vw = 0,\r\n vih = 0,\r\n vihChangeThreshold = 90; // value larger than IOS Safari viewport height change on scroll\r\n\r\nconst vpSizeCheck = (w,h) => {\r\n if(w != vw || h != vh) {\r\n window.requestAnimationFrame(() => {\r\n // only change --vpInitialHeight if the width has changed or the height difference > 40px;\r\n if(w != vw || (w == vw && Math.abs(h - vih) > vihChangeThreshold)) {\r\n vih = h;\r\n document.documentElement.style.setProperty('--vpInitialHeight', `${vih}px`);\r\n }\r\n // vw\r\n if(w != vw) {\r\n vw = w;\r\n document.documentElement.style.setProperty('--vpWidth', `${vw}px`);\r\n }\r\n // vh\r\n if(h != vh) {\r\n vh = h;\r\n document.documentElement.style.setProperty('--vpHeight', `${vh}px`);\r\n }\r\n });\r\n }\r\n};\r\n\r\n// add element to body\r\n\r\nconst vpSizer = document.createElement('div');\r\nvpSizer.setAttribute('id','vp-sizer');\r\nvpSizer.setAttribute('aria-hidden','true');\r\nvpSizer.setAttribute('style','position:fixed;z-index:-1;top:0;left:0;bottom:0;right:0;pointer-events:none');\r\n$body.appendChild(vpSizer);\r\n\r\n// add resize observer\r\n\r\nconst vpSizerResizeObserver = new ResizeObserver(entries => {\r\n for (let entry of entries) {\r\n const cr = entry.contentRect;\r\n vpSizeCheck(cr.width,cr.height);\r\n }\r\n});\r\n\r\nvpSizerResizeObserver.observe(vpSizer);"],"names":["ResizeObserver","window","Polyfill","$body","document","querySelector","vh","vw","vih","vpSizeCheck","w","h","requestAnimationFrame","Math","abs","documentElement","style","setProperty","vpSizer","createElement","setAttribute","appendChild","entries","cr","contentRect","width","height","observe"],"sourceRoot":""}