<div class="demo">
  <div class="cell">
    <h2>SVG &lt;rect&gt;</h2>

    <svg version="1.1" id="svg" class="container" width="260" height="200"  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 260 200" xml:space="preserve">
        <rect id="svgRectangle" class="animated" x="20" y="60" width="220" height="80" fill="#91e600" />
    </svg>
  </div>
  <div class="cell">
    <h2>&lt;div&gt;</h2>
    <div class="container" style="width:260px; height:200px; position:relative;">
      <div id="divRectangle" class="animated"></div>
      
    </div>
  </div>
</div>
<div id="nav">
  <h3 id="message"></h3>

<div id="slider" style = "width:465px; float:left"></div>
 <button id="play" class="dark-grey-button club-demo-button">play</button>
</div>


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

External CSS

  1. https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css
  2. https://codepen.io/GreenSock/pen/ee8ac247ddeb87e229d660127c6fe73d

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js
  2. https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js
  3. https://unpkg.co/gsap@3/dist/gsap.min.js
  4. https://unpkg.com/gsap@3/dist/TextPlugin.min.js