Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Hide a target when it is not being animated?</h1>
<div id='overlay' style='background-color:green;position:absolute;width:100px;height:100px;'></div>
<br/><br/><br/><br/><br/><br/>
<b>How can I hide this target in a time slice on a long time line when it is not being actively animated?</b></br>
Even better if the object is invisible from the beginning too.<br/><br/>

Implementation details are:
<ul>
<li>Animation commands are added in a loop reading from server JSON in real time</li>
<li>At the time to() is called, it is not known when the animation will ultimately stop</li>
<li>All to() arguments are variable in terms of the naive receiving JS code </li>
</ul>

              
            
!

CSS

              
                #overlay {
  opacity: 0;
}
              
            
!

JS

              
                // Initialise timeline, 3465 is the known length of video media
t = new TimelineMax();
t.to(document.body, 3465, {opacity:1});

// Animation commands are added in a loop reading from server JSON
// Animation commands are for very short durations (typically 0.04 seconds)
// All to() arguments are variable in terms of the naive receiving JS code 
t.to('#overlay', 1, {x:"+=100", autoAlpha:1, ease:Power2.easeInOut, clearProps:'opacity'}, 0)
// ... time passes in both the browser and GreenSock timeline ...
t.to('#overlay', 1, {x:"+=100", autoAlpha:1, ease:Power2.easeInOut, clearProps:'opacity'}, 3)
t.to('#overlay', 1, {x:"+=100", autoAlpha:1, ease:Power2.easeInOut, clearProps:'opacity'}, 5)
t.to('#overlay', 1, {x:"+=100", autoAlpha:1, ease:Power2.easeInOut, clearProps:'opacity'}, 7)
t.to('#overlay', 1, {x:"+=100", autoAlpha:1, ease:Power2.easeInOut, clearProps:'opacity'}, 9)

              
            
!
999px

Console