Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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

              
                <div class="box gsap">GSAP</div>
<div class="box css">CSS Animation</div>
              
            
!

CSS

              
                /* The CSS animation being used */
@keyframes move-it {
  to { transform: translateX(100vw) translateX(-100%) rotate(360deg); }
}

.box {
  width: 200px;
  height: 200px;
  background: green;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFF;
}

.css { background: orange; }

html { overflow: hidden; }

              
            
!

JS

              
                console.clear(true);

var tl = new TimelineMax();

var duration = 2;
var ease = 'Power2.easeInOut';

/* Setting up the CSS animation on the element */
tl.set('.css', {
  animationName: 'move-it', // Animation name
  animationPlayState: 'paused', // Pause the animation so it doesn't play 
  animationTimingFunction: 'linear', // Linear easing so the animation follows GSAP's easing 
  animationDuration: duration + 's', // Length of the tween
  animationDelay: '0s', // Ensure there's no delay
  // Infinite iteration and alternating direction to prevent visual glitches when reaching 100% progress
  animationIterationCount: 'infinite', 
  animationDirection: 'alternate'
});

/* Now we tween the animation-delay to -duration */
tl.to('.css', duration, {
  animationDelay: -duration + 's',
  ease: ease,
  onUpdate: function(){
    TweenLite.set(this.target, { animationName: '' });
    TweenLite.set(this.target, { animationName: 'move-it' });
  }
});

/* Equivalent animation in GSAP, to show the animation is in sync */
tl.to('.gsap', duration, {
  x: window.innerWidth,
  xPercent: -100,
  rotation: 360,
  ease: ease
}, 0);

GSDevTools.create();


              
            
!
999px

Console