{"version":3,"file":"2458.32fa732cb9e09e5e934e.js","mappings":"2LACA,MAAMA,EAAiBC,OAAOD,gBAAkBE,EAAAA,GAEhD,MAAMC,EAEFC,WAAAA,CAAYC,GAERC,KAAKD,GAAKA,EACVC,KAAKC,MAAQ,EACbD,KAAKE,QAAU,KACf,IAAIC,EAAeH,KAAKD,GAAGK,cAAc,OACzCJ,KAAKK,UAAYF,EACjBH,KAAKM,IAAMN,KAAKK,UAAYF,EAAeH,KAAKD,GAChDC,KAAKO,QAAUP,KAAKK,UAAYL,KAAKD,GAAGS,iBAAiB,UAAY,KAErER,KAAKS,GAAK,IAAIf,GAAegB,IACzB,IAAK,IAAIC,KAASD,EAAS,CACvB,MAAME,EAAKD,EAAME,YACjB,IAAIC,EAAIC,KAAKC,KAAKJ,EAAGX,OAClBa,GAAKd,KAAKC,QACTD,KAAKC,MAAQa,EACbG,aAAajB,KAAKE,SAClBF,KAAKE,QAAUgB,YAAW,KACtBlB,KAAKmB,QAAQ,GACd,IAEX,KAEJnB,KAAKS,GAAGW,QAAQpB,KAAKM,IACzB,CAEAa,MAAAA,GACInB,KAAKM,IAAIe,aAAa,QAAS,GAAErB,KAAKC,WACnCD,KAAKK,WAAaL,KAAKO,QAAQe,OAAS,GAAGtB,KAAKO,QAAQgB,SAAQC,IAC/DA,EAAEH,aAAa,QAAS,GAAErB,KAAKC,UAAU,GAEjD,EAKG,SAASwB,EAAWC,GACvBA,EAASH,SAASI,IAEQ,IAAlBA,EAAKC,UACL,IAAI/B,EAAa8B,EACrB,GAER,C","sources":["webpack://National Motor Museum Trust/./wwwroot/app/src/js/data-sizes-js-fix.js"],"sourcesContent":["import { ResizeObserver as Polyfill } from '@juggle/resize-observer';\r\nconst ResizeObserver = window.ResizeObserver || Polyfill;\r\n\r\nclass DataSizesFix {\r\n\r\n constructor(el) {\r\n // store element\r\n this.el = el;\r\n this.width = 0;\r\n this.timeout = null;\r\n let pictureImage = this.el.querySelector('img');\r\n this.isPicture = pictureImage;\r\n this.img = this.isPicture ? pictureImage : this.el;\r\n this.sources = this.isPicture ? this.el.querySelectorAll('source') : null;\r\n // add resizeObserver\r\n this.ro = new ResizeObserver(entries => {\r\n for (let entry of entries) {\r\n const cr = entry.contentRect;\r\n let w = Math.ceil(cr.width);\r\n if(w != this.width) {\r\n this.width = w;\r\n clearTimeout(this.timeout);\r\n this.timeout = setTimeout(() => {\r\n this.update();\r\n }, 50);\r\n }\r\n }\r\n });\r\n this.ro.observe(this.img);\r\n }\r\n\r\n update() {\r\n this.img.setAttribute('sizes',`${this.width}px`);\r\n if(this.isPicture && this.sources.length > 0) this.sources.forEach(s => {\r\n s.setAttribute('sizes',`${this.width}px`);\r\n });\r\n }\r\n\r\n}\r\n\r\n// export the default function to create\r\nexport function createFrom(wrappers) {\r\n wrappers.forEach((node) => {\r\n // if node is an element\r\n if (node.nodeType === 1) {\r\n new DataSizesFix(node);\r\n }\r\n });\r\n}"],"names":["ResizeObserver","window","Polyfill","DataSizesFix","constructor","el","this","width","timeout","pictureImage","querySelector","isPicture","img","sources","querySelectorAll","ro","entries","entry","cr","contentRect","w","Math","ceil","clearTimeout","setTimeout","update","observe","setAttribute","length","forEach","s","createFrom","wrappers","node","nodeType"],"sourceRoot":""}