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 style="width: 700px; margin: 0 auto; overflow: hidden; background: rgba(255, 255, 255, 0.375);">
  <p>
    <button id="btn1">Play Timeline</button>
  </p>
  <div id="div1"></div>
  <div id="div2"></div>
  <div id="div3"></div>

  <div id="slider"><span id="op">0</span></div>
</div>
              
            
!

CSS

              
                body
{
	background:#222;
	margin:0;
}

#div1, #div2, #div3
{
	height:100px;
	width:100px;
	position:relative;
	border:solid 1px #fff;
	background:blue;
	margin:20px;
	border-radius:10px;
}

#div2
{
	background:red;
}

#div3
{
	background:green;
}

p
{
	margin:20px 0 0 20px;
}
              
            
!

JS

              
                console.clear();

TweenLite.onOverwrite = function(overwrittenTween, overwritingTween, target, properties){
  console.log("overwrite");
  console.log("overwrittenTween", overwrittenTween);
  console.log("overwrittenTween.target", overwrittenTween.target);
  console.log("overwritingTween.startTime()", overwritingTween.startTime());
}

var tl = new TimelineMax(),
	div1 = $("div#div1"),
	div2 = $("div#div2"),
	div3 = $("div#div3"),
	btn1 = $("button#btn1"),
	btn2 = $("button#btn2");

var processedAnimations = {
  "entrance": {
    "1250": [
      {
        "layer": "div1",
        "speed": 0.79,
        "time": 1250,
        "easing": "Power1.easeInOut"
      }
    ],
    "1260": [
      {
        "layer": "div2",
        "speed": 0.79,
        "time": 1260,
        "easing": "Power1.easeInOut"
      },
      {
        "layer": "div3",
        "speed": 0.79,
        "time": 1260,
        "easing": "Power1.easeInOut"
      }
    ]
  },
  "exit": {
    
  }
};

function addProcessedAnimationsToTimeline(timeline)
{
   var temp        = [],
       elements    = [];
  
  if(processedAnimations)
  {
    for(var stageType in processedAnimations)
    {
      if(processedAnimations.hasOwnProperty(stageType))
      {
        var animationTimings = processedAnimations[stageType];

        if(animationTimings)
        {
          for(var time in animationTimings)
          {
            if(animationTimings.hasOwnProperty(time))
            {
              var animationItems  = animationTimings[time],
                  timeInSeconds   = time / 1000;

              if(animationItems && animationItems.length)
              {
                var animationItemLength = animationItems.length;

                for(var a = 0; a < animationItemLength; a++)
                {
                  var animationSettings   = animationItems[a],
                      animationName       = animationSettings.animation,
                      customSpeed         = animationSettings.speed,
                      customEasing        = animationSettings.easing,
                      layerId             = animationSettings.layer,
                      layerElement        = document.getElementById(layerId);

                  if(layerId && layerElement)
                  {
                    var processedSettings =   {"name":"zoomInCenter","type":"Zooming","stageType":"entrance","defaultDuration":0.4,"defaultEasing":"Power1.easeInOut","series":[{"scale":0, x: 750, rotation: '-=360'}]};

                    if(processedSettings)
                    {
                      var layerElementStyles = layerElement.style;

                      var defaultSet          = processedSettings.defaultSet || {rotation: 0},
                          duration            = customSpeed || processedSettings.defaultDuration,
                          easing              = customEasing || processedSettings.defaultEasing,
                          animationSeries;
                      
                      if(processedSettings.type == 'Text Effect')
                      {

                      }
                      else
                      {
                        animationSeries = processedSettings.series;

                        if(defaultSet)
                        {
                          timeline.set(layerElement, defaultSet);
                        }
                        
                        for(var i = 0; i < animationSeries.length; i++)
                        {
                          var animation           = animationSeries[i],
                              animationDuration   = duration || animation.duration || .5,
                              animationEasing     = easing || animation.ease || 'Power1.easeInOut',
                              applyCustomEasing   = true;

                          try
                          {
                            var evaluatedEase = eval(animationEasing);
                          }
                          catch(e)
                          {
                            applyCustomEasing = false
                          }

                          if(applyCustomEasing)
                          {
                            // Apply easing if the eval() returned
                            animation = jQuery.extend(true, animation, {
                              ease: evaluatedEase
                            });
                          }

                          var tween;

                          // Disable immediate rendering of animation
                          animation.immediateRender = true;

                          // Set up TweenLite.from() for entrance animations
                          if(stageType == 'entrance')
                          {
                            
                            tween = TweenLite.from(layerElement, animationDuration, animation);
                          }
                          // Set up TweenLite.to() for exit animations
                          else if(stageType == 'exit')
                          {
                            tween = TweenLite.to(layerElement, animationDuration, animation);
                          }

                          // If tween is found, add tween to timeline
                          if(tween)
                          {
                            timeline.add(tween, timeInSeconds);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

function playAnimationTimeline()
{
  tl = new TimelineMax({
    paused:     true,
    onComplete: onComplete,
    onUpdate:   onUpdate
  });

  addProcessedAnimationsToTimeline(tl);
  
  tl.play();

  function onComplete()
  {
    
  }

  function onUpdate()
  {
    var progress = tl.progress();
    $("#slider").slider("value", tl.progress() *300);
    $("#op").html((tl.progress() * 30).toFixed(2));
  }
}

btn1.click(function()
{
	playAnimationTimeline();
});

// slider
$("#slider").slider({
  range: false,
  min: 0,
  max: 300,
  step:.1,
  slide: function ( event, ui ) {
    tl.pause();
    //adjust the timeline's progress() based on slider value
    tl.progress(ui.value / 100);
    }
});	
              
            
!
999px

Console