body {
background-color: #1d1d1d;
color: #999;
font-family: Arial, sans-serif;
margin-left:18px;
}
strong {
color: #DDD;
}
h2 {
font-size:3em;
line-height:1em;
margin-bottom:0.1em;
color: white;
font-weight: 400;
margin-top: 5px;
}
a, a:hover, a:visited {
color:#71B200;
}
.container {
border: 1px solid #666666;
overflow: hidden;
background:black;
}
.demo {
display: table;
font-family: monospace;
}
.cell {
display: table-cell;
padding-right: 18px;
position: relative;
text-align: center;
}
#divRectangle {
position: absolute;
}
#divRectangle {
background-color: #91e600;
width: 220px;
height: 80px;
top: 60px;
left: 18px;
}
button#play {
float:right;
margin-top:-8px;
margin-right:10px;
}
#nav {
width:560px;
margin:0px auto;
}
.demo {
width:560px;
margin:0px auto;
}
gsap.registerPlugin(TextPlugin);
var elements = $("#svgRectangle, #divRectangle"),
message = $("#message"),
tl = gsap.timeline({onUpdate:updateSlider, defauts:{duration: 1}});
gsap.defaults({ smoothOrigin: false });
//very basic TimelineLite code to animate elements and change the text.
//notice that both elements (#divRectangle and #svgRectangle) both use the exact same tweens
tl.set(message, {text:'{rotation:360, transformOrigin:"50% 50%"}'})
.to(elements, {rotation:360, transformOrigin:"50% 50%"}, "+=1")
.set(message, {text:'{rotation:"+=360", transformOrigin:"right bottom"}'}, "+=1")
.to(elements, {rotation:"+=360", transformOrigin:"right bottom"})
.set(message, {text:'{scale:0, transformOrigin:"0px 0px"}'}, "+=1")
.to(elements, {scale:0, transformOrigin:"0px 0px"})
.set(message, {text:'{scale:1, transformOrigin:"100% 0%"}'}, "+=1")
.to(elements, {scale:1, transformOrigin:"100% 0%"})
.set(message, {text:'{scaleY:0, transformOrigin:"0% 50%"}'}, "+=1")
.to(elements, {scaleY:0, transformOrigin:"0% 50%"})
.set(message, {text:'{scale:1, transformOrigin:"50% bottom"}'}, "+=1")
.to(elements, {scale:1, transformOrigin:"50% bottom"})
.set(message, {text:'{scale:0.5, rotation:360, transformOrigin:"50% 50%"}'}, "+=1")
.to(elements, {scale:0.5, rotation:360, transformOrigin:"50% 50%"})
$("#slider").slider({
range: false,
min: 0,
max: 1,
step:0.001,
slide: function ( event, ui ) {
tl.progress( ui.value ).pause();
}
});
function updateSlider() {
$("#slider").slider("value", tl.progress());
}
$("#play").click(function(){
if(tl.progress() === 1){
tl.restart()
} else {
tl.play();
}
})
tl.pause();
//be sure to test this in multiple browsers