NitroAd
NitroAd placement.
Constructors
new NitroAd(id: string, options: NitroAdOptions): NitroAd
Parameters
id(string) — placement idoptions(NitroAdOptions) — Placement settings
Returns
NitroAd
Properties
id: string
The unique id attribute for this placement.
options: NitroAdOptions
Placement settings.
Methods
getState(): AdState | null
Lifecycle state of this placement's most recent ad request, or null if no request has started yet.
Returns
AdState| null
onNavigate(href?: string): void
In single-page applications, this can be called to clear and refresh the placement when navigating to a different URL. Passing in a href prop for an interstitial format will navigate to the given href after the interstitial is dismissed.
Remarks
In an SPA, where navigating to a new page doesn't trigger a full page refresh, you can keep a reference to the NitroAd object you receive when calling createAd, and call this from your framework's navigation event.
Alternatively, you can remove the container div from the DOM, then recreate it and call createAd again. The div being removed will be detected, and any related resources will be freed.
Parameters
href(string, optional)
Returns
void
renderContainers(): Promise<boolean>
returns true if ad rendering should continue returns false if ad rendering should be halted
Returns
Promise<boolean>— boolean
videoConfig(cfg: VideoPlayerConfig): void
Merge config into the live Aniview video player in real time. Only valid on video or video-nc format placements — logs an error otherwise. Safe to call at any time after the unit renders; calling before the player is initialized is a no-op (the Aniview module will log a warning).
Parameters
cfg(VideoPlayerConfig)
Returns
void
Example
const ad = await window.nitroAds.createAd('unit-1', { format: 'video', ... });
ad.videoConfig({ floating: { top: 80 } });