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

              
                <main>
  <h1>Nested animation pausing demo</h1>
  <p><strong>When an animation (tween or timeline) is nested within a timeline, the parent timeline's playhead will continue to run even if the child animation is paused.</strong></p>
  
  <p>The animation below is nested within a parent timeline. If you pause and resume the child timeline, you will likely see a visual jump because the parent timeline's playhead is still running.</p>
  
  <p>In most cases it makes sense to pause the timeline that contains the other animations instead.</p>
  
  <button id="toggle-parent">Pause Parent</button>
  <button id="toggle-child">Pause Child</button>
</main>

<div class="box-wrapper">
  <div class="box"></div>
</div>
<div class="box-wrapper">
  <div class="box"></div>
</div>
<div class="box-wrapper">
  <div class="box"></div>
</div>
<div class="box-wrapper">
  <div class="box"></div>
</div>

              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Signika+Negative:300,400&display=swap');
body { 
  font-family: "Signika Negative", sans-serif; 
  font-weight: 300;
}

main {
  max-width: 800px;
  margin-bottom: 20px;
}

.box {
  height: 20px;
  background: blue;
  border:2px solid white;
  transform-origin: left center;
}

              
            
!

JS

              
                const childAnimation = gsap.from('.box', {scaleX: 0.01, stagger: 0.5});

const parentTimeline = gsap.timeline({ repeat: -1 });
parentTimeline.add(childAnimation);

const toggleChildButton = document.getElementById("toggle-child");
toggleChildButton.addEventListener("click", function(event) {
  if (event.target.innerHTML === "Pause Child") {
    event.target.innerHTML = "Resume Child";
    childAnimation.pause();
  } else {
    event.target.innerHTML = "Pause Child";
    childAnimation.resume();
  }
});

const toggleParentButton = document.getElementById("toggle-parent");
toggleParentButton.addEventListener("click", function(event) {
  if (event.target.innerHTML === "Pause Parent") {
    event.target.innerHTML = "Resume Parent";
    parentTimeline.pause();
  } else {
    event.target.innerHTML = "Pause Parent";
    parentTimeline.resume();
  }
});

              
            
!
999px

Console