Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
fastasleep

Start animation after offscreen iframe enters window?

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Apologies if this has been covered, but I can't find anything.

 

If your banner is offscreen on window load, is there any way to detect when the user scrolls to a point where the iframe is on screen at which point you can fire the GSAP animation? 

 

I realize there's the Enabler.js for Doubleclick ads which I believe has this feature, but I'm dealing with another ad server. I feel there must be some way to detect this state and prevent animations from starting off screen and potentially finishing before the user even sees the banner.

 

Thanks!

Link to comment
Share on other sites

I don't think that the Enabler.js has that feature... correct me if I am wrong.

FLITE has a "in view" event and Celtra has a way to detect the position of the iframe in the page... so you will need to write your own script :(

Fred

Link to comment
Share on other sites

Hi Frederick, 

 

Welcome to the forums. 

DoubleClick's enabler has an isVisible() method to check if the iframe is in the viewport

 

https://www.google.com/doubleclick/studio/docs/sdk/html5/en/class_studio_Enabler.html (see first code demo).

 

Fastasleep,

 

Keep in mind that adservers (like DoubleClick) run code on the page that hosts your banner. This makes it very easy for them to know which iframe is pulling in your ad and when the iframe enters the viewport. I think it will be pretty tricky to create a script that works cross-browser that can run inside an iframe and tries to query the DOM of the parent to try to find that iframe. I've never tried, its just my guess that it won't be simple.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×