mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-08-06 06:47:38 +00:00
add oddbird polyfill - not quite working
Not quite working yet. polyfill is loaded, but positioned elements are spanning whole viewport. Parking this for now.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import './anchorPositioningPolyfill.less';
|
||||
|
||||
let polyfillPromise;
|
||||
|
||||
const supportsAnchorPositioning = ()=>'anchorName' in document.documentElement.style;
|
||||
|
||||
const afterInitialRender = ()=>new Promise((resolve)=>{
|
||||
requestAnimationFrame(()=>{
|
||||
requestAnimationFrame(resolve);
|
||||
});
|
||||
});
|
||||
|
||||
export const bootstrapAnchorPositioningPolyfill = ()=>{
|
||||
if(supportsAnchorPositioning()) return Promise.resolve(false);
|
||||
if(polyfillPromise) return polyfillPromise;
|
||||
|
||||
polyfillPromise = afterInitialRender()
|
||||
.then(async ()=>{
|
||||
const { default: polyfill } = await import('@oddbird/css-anchor-positioning/fn');
|
||||
await polyfill();
|
||||
return true;
|
||||
})
|
||||
.catch((error)=>{
|
||||
polyfillPromise = undefined;
|
||||
throw error;
|
||||
});
|
||||
|
||||
return polyfillPromise;
|
||||
};
|
||||
Reference in New Issue
Block a user