Jump to content
Search Community

Manipulating timeline inside iframe

xjure test
Moderator Tag

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

function handleComplete(evt) {
    exportRoot = new lib.somersbycoop728x90fr();

    stage = new createjs.Stage(canvas);
    stage.addChild(exportRoot);
    stage.update();

    createjs.Ticker.setFPS(lib.properties.fps);
    createjs.Ticker.addEventListener("tick", stage);

    // console.log(exportRoot);
    // globalTimeline = TimelineLite.exportRoot(exportRoot);

}

Is there any option to pause, resume, and seek timeline of banner inside iframe?
Above code is from banner.

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums,

 

If your banner and parent document are loaded from the same domain, then I believe yes.

Your globalTimeline var will also have to be attached to window (be globally accessible).

 

This stackoverflow post illustrates how to target a variable in an iframe from parent:

 

https://stackoverflow.com/questions/8296141/how-to-access-iframes-javascript-objects-from-parent-page

 

 

  • Like 2
Link to comment
Share on other sites

I tried to get that variable but globalTimeline is not defined. 

We have one banner that has one stage or scene which is in loop even timeline is paused.

 

function Pause() {
  if (stage && stage.children) {

    var i, l = stage.children.length;

    for (i = 0; i < l; i++) {
      var child = stage.children[i];

      child.timeline.setPaused=true;

      if ("gotoAndStop" in child)
        var pos = parseInt(child.timeline.position);
      child.gotoAndStop(pos);
    }

    $('#range').val(pos);
    stopSlider();
  }

This is part of the code I use to pause the timeline, do you think this is correct way?

Link to comment
Share on other sites

Sorry, I have no idea what that code is supposed to do. I don't see globalTimeline defined nor do I know what stage.children is or what child.timeline.setPaused = true is. That looks more like CreateJS code and not GreenSock code.

 

We really have to stay focused on the GSAP API. 

I would suggest you set up a VERY basic demo of a page that loads an iframe with a single variable or object in it. Try accessing that variable from the parent. If you get that to work, re-assign that variable to your timeline. Unfortunately If you can't target a single variable in an iframe then there is no point in dealing with the complexity of the second part (timelines, parents, stages, loops, etc). 

 

I haven't dealt with iframes much and there are quite a few security measures that browsers impose. I think you will do best on stackoverflow or somewhere else that deals with more general webdev issues. 

 

 

  • 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.
×
×
  • Create New...