Merge pull request #169 from reuters-graphics/ads-infinity
unset ad iframe width from CSS reset. cleanup ads slots onDestroy. En…
This commit is contained in:
commit
1837dbb8e4
2 changed files with 21 additions and 0 deletions
|
|
@ -39,7 +39,25 @@
|
|||
window.graphicsAdQueue = window.graphicsAdQueue || [];
|
||||
window.graphicsAdQueue.push(adSlot);
|
||||
}
|
||||
|
||||
return () => {
|
||||
// @ts-ignore
|
||||
const freestar = window?.freestar;
|
||||
if (freestar) {
|
||||
freestar.queue.push(function () {
|
||||
freestar.deleteAdSlots(adId);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<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) => {
|
||||
const { onload, async = true } = attributes || {};
|
||||
|
||||
const existingScript = document.querySelector(`script[src="${src}"]`);
|
||||
if (existingScript) return;
|
||||
|
||||
const script = document.createElement('script');
|
||||
script.addEventListener('load', onload);
|
||||
script.async = async;
|
||||
|
|
|
|||
Loading…
Reference in a new issue