How to start Javascript at inscreen?

I have made a graphic at our newspaper with an animation and timeline. Works well, but I want the graphic to start when it is INSCREEN. It will be placed almost at the bottom at the article, and when the reader come there, the animation is finished. How can this be done? Her is a link (without the long article). https://www.dagbladet.no/nyheter/aidsruta/71947423

nice graphic :slight_smile:

your homepage needs a library that detects if an element is within the viewport.
something like: https://github.com/ChrisCavs/bounds.js

as the embed is an iframe you’ll then need to postMessage (you can search the forum) with the iFrame as target and there has to be a onmessage-listener within the hypedoc to receive the event and start the considered timeline.

it’s not that trivial, but if you plan to publish regulary it’s worth the efford :slight_smile:

3 Likes