Created
January 26, 2020 17:37
-
-
Save mpasteris/c422a675bcf4d5840bb9f5d4789912fa to your computer and use it in GitHub Desktop.
GSAP basic repeat and onRepeat
This file contains hidden or 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
<link href='https://fonts.googleapis.com/css?family=Asap:400,700' rel='stylesheet' type='text/css'> | |
<link href='https://fonts.googleapis.com/css?family=Signika' rel='stylesheet' type='text/css'> | |
<div id="demo"> | |
<div class="box green" id="greenBox">0</div> | |
</div> |
This file contains hidden or 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
//basic illustration of TweenMax's repeat, repeatDelay, yoyo and onRepeat | |
var box = document.getElementById("greenBox"), | |
count = 0, | |
tween; | |
tween = gsap.to(box, {duration: 2, left:"700px", repeat:10, yoyo:true, onRepeat:onRepeat, repeatDelay:0.5, ease:"none"}); | |
function onRepeat() { | |
count++; | |
box.innerHTML = count; | |
gsap.set(box, {backgroundColor:"hsl(" + Math.random() * 255 + ", 90%, 60%)"}); | |
} |
This file contains hidden or 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
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script> |
This file contains hidden or 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 { | |
background-color:#1d1d1d; | |
font-family: "Asap", sans-serif; | |
color:#989898; | |
margin:10px; | |
font-size:16px; | |
} | |
#demo { | |
height:100%; | |
position:relative; | |
overflow:hidden; | |
} | |
.box { | |
width:100px; | |
height:100px; | |
position:relative; | |
border-radius:6px; | |
margin-top:4px; | |
text-align:center; | |
line-height:100px; | |
color:black; | |
font-size:80px; | |
} | |
.green{ | |
background-color:#6fb936; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment