unset ad iframe width from CSS reset. cleanup ads slots onDestroy. Ensure loaded ad scripts aren't already in head
This commit is contained in:
parent
db9645ad0e
commit
e64110f4d1
2 changed files with 21 additions and 0 deletions
|
|
@ -39,7 +39,25 @@
|
||||||
window.graphicsAdQueue = window.graphicsAdQueue || [];
|
window.graphicsAdQueue = window.graphicsAdQueue || [];
|
||||||
window.graphicsAdQueue.push(adSlot);
|
window.graphicsAdQueue.push(adSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
// @ts-ignore
|
||||||
|
const freestar = window?.freestar;
|
||||||
|
if (freestar) {
|
||||||
|
freestar.queue.push(function () {
|
||||||
|
freestar.deleteAdSlots(adId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div data-freestar-ad="{dataFreestarAd || null}" id="{adId}"></div>
|
<div data-freestar-ad="{dataFreestarAd || null}" id="{adId}"></div>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
div {
|
||||||
|
:global(iframe) {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ interface attributesInterface {
|
||||||
export const loadScript = (src: string, attributes?: attributesInterface) => {
|
export const loadScript = (src: string, attributes?: attributesInterface) => {
|
||||||
const { onload, async = true } = attributes || {};
|
const { onload, async = true } = attributes || {};
|
||||||
|
|
||||||
|
const existingScript = document.querySelector(`script[src="${src}"]`);
|
||||||
|
if (existingScript) return;
|
||||||
|
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
script.addEventListener('load', onload);
|
script.addEventListener('load', onload);
|
||||||
script.async = async;
|
script.async = async;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue