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

              
                <div id="wrapper">

    <div class="tick">1</div>
    <div class="tick">2</div>
    <div class="tick">3</div>
    <div class="tick">4</div>
    <div class="tick">5</div>
    <div class="tick">6</div>
    <div class="tick">7</div>
    <div class="tick">8</div>
    <div class="tick">9</div>
    <div class="tick">10</div>
    
</div>
              
            
!

CSS

              
                body
{
    margin:0;
    background:#444;
}
#wrapper
{
  position:relative;
  margin-left:5px;
}
.container
{
  position:absolute;
  margin-top:0;
  margin-left:0;
}
.tick
{
    width:50px;
    height:50px;
    margin:5px;
    background:#00f;
    position:relative;
    border:solid 1px #fff;
    color:#fff;
    text-align:center;
    font-weight:bold;
    font-size:22px;
    line-height:50px;
}
              
            
!

JS

              
                CSSPlugin.defaultTransformPerspective = 600;

var count = 1,

	masterTL = new TimelineMax({repeat:-1, yoyo:true}),
	tl1 = new TimelineMax({delay:.5}),//no matter what there'll be at least one timeline, we create it manually
	
	ticks = $("div.tick"),
	ticksAmount = ticks.length,
	setAmount = 3,//this number sets how many elements will be animated on each cycle
	
	//this array will contain the nested timelines.
	//Is important to the code itself not adding the nested timelines to the parent one
	lineArray = [tl1];

masterTL.add(tl1)//we add the first timeline to the parent one

$.each($("div.tick"),function(index, element)
{
	//add the current element to the last timeline of the array
  lineArray[count - 1].from(element, .7, {x: 100, rotationX: -90, transformOrigin: "50% 0px", ease: Back.easeOut});
	
	if( (index % setAmount) == (setAmount-1) )
	{
		//this is to get the DOM elements of the timeline in order to tween their opacity
		var lineTargets = getLineTargets(lineArray[count - 1]);
    lineArray[count - 1].to(lineTargets, .3, {opacity:0, delay:.2, display:'none'});
		
		//we create a new timeline once the last on of the array has the number of elements set for each cycle
		count++;
		var newLine = 'tl' + count;
		lineArray.push(newLine);
		lineArray[count - 1] = new TimelineMax({delay:.5});//this is now the last timeline of the array
		masterTL.add(lineArray[count - 1]);//we add the timeline to the parent one
	}
	
	//if the amount of elements can't be divided by the cycle number run this code when the loop is at the last element
	if(index == (ticksAmount - 1))
	{
		//if the number of elements can be divided by the amount of each cycle this array comes empty
		var lineTargets = getLineTargets(lineArray[count - 1]);
		lineArray[count - 1]
      .to({},.5,{})
      .to(lineTargets, .3, {opacity:0});
	}
});

//returns an array with the DOM elements of the timeline to tween their opacity to 0
function getLineTargets(tween)
{
	var nestedTweens = tween.getChildren(),
		tweenTargets = [];
	$.each(nestedTweens, function(index, element)
	{
		tweenTargets.push(element.target);
	});
	return tweenTargets;
}
              
            
!
999px

Console