Loads TweenMax and jQuery to enable the creation of hassle-free demos
-
-
Save roachhd/f5624d9dd1fc5ba0fb8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="wall"></div> | |
<div class="nav"> | |
<button id="restart">play</button> | |
</div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tl = new TimelineLite(); | |
function createWall(container, rows, cols) { | |
for (var r = rows; r > -1; r--){ | |
var y = r * 22; | |
for(var c = 0; c < cols; c++){ | |
var x = (c * 60) + getRandom(2, 8); | |
x = (r%2==0) ? x : x + 20; | |
var brick = $("<div class='brick'></div>").appendTo(container); | |
brick.distance = x; | |
TweenLite.set(brick, {x:x, y:y}) | |
} | |
} | |
} | |
createWall(".wall", 15, 8) | |
tl.staggerFrom(".brick", 0.5, {y:-20, ease:Power2.easeIn}, 0.05) | |
function getRandom(min, max) { | |
return min + Math.random() * (max - min); | |
} | |
$("#restart").on("click", function() { | |
tl.restart(); | |
}) | |
/* This Pen Loads the Following | |
jQuery: latest version | |
TweenMax: latest version | |
-TweenLite | |
-TweenMax | |
-TimelineLite | |
-TimelineMax | |
-CSSPlugin | |
-BezierPlugin | |
-DirectionalRotationPlugin | |
-AttrPlugin | |
-RoundPropsPlugin | |
-EasePack | |
Please use the minimal amount of code possible to recreate the problem you are experiencing. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
font-family:sans-serif; | |
background:#1d1f20; | |
} | |
.brick{ | |
width:50px; | |
height:20px; | |
position:absolute; | |
background-color:#930; | |
} | |
.wall { | |
position:relative; | |
left:-50px; | |
width:400px; | |
height:350px; | |
overflow:hidden; | |
background:#ccc; | |
} | |
.nav { | |
width:600px; | |
text-align:right; | |
} | |
button { | |
padding:10px; | |
margin:10px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment