GSAP Spinning Ticket

In this example below you will see how to do a GSAP Spinning Ticket with some HTML / CSS and Javascript

Simple spinning element as if it were hanging from a tree.

Thumbnail
This awesome code was written by mrjonnywood, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright mrjonnywood ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>GSAP Spinning Ticket</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <link href='https://fonts.googleapis.com/css?family=Meddon' rel='stylesheet' type='text/css'>

<div id="wrap">
  <div id="wish">
      <p>&emsp;&emsp;&emsp;Merry Christmas!</p>
  </div>
</div>
  <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js'></script>
<script src='https://s.cdpn.io/16327/sizzle.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/mrjonnywood/gsap-spinning-ticket-myeNgG */
* {
  box-sizing: border-box;
}
body {
  font-family: 'Meddon', cursive;
  background: #F8F8F8;
  -webkit-font-smoothing: antialiased;
}
#wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  margin: -200px 0 0 -200px;
  width: 400px;
  height: 400px;
  border-radius: 200px;
  background: #89B650;
}
#wrap:after {
  position: absolute;
  top: 0;
  left: 200px;
  display: block;
  width: 1px;
  height: 200px;
  content: "";
  background: white;
}
#wish {
  z-index: 2;
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -50px 0 0 -100px;
  width: 200px;
  height: 100px;
  border-radius: 0 50px 50px 0;
  background: white;
  font-size: 1.2em;
  line-height: 1.8;
  text-align: left;
  -webkit-transform: rotate(-90deg);
          transform: rotate(-90deg);
}
#wish p {
  padding: 16px 0 0 20px;
  margin: 0;
}
#wish:before {
  content: "";
  position: absolute;
  top: 50%;
  right: 20px;
  display: block;
  margin: -10px 0 0 0;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #89B650;
}


/*Downloaded from https://www.codeseek.co/mrjonnywood/gsap-spinning-ticket-myeNgG */
var container = $("#wrap"),
    ticket = $("#wish"),
    text = $("#wish p");

var tl = new TimelineMax();

tl.set(container, {perspective:400});
tl.set(text, {
  backfaceVisibility:"hidden",
  transformStyle: "preserve-3d"
});

tl.from(ticket, 6, {
  ease: Power2.easeInOut,
  rotationX:360,
  repeat: -1,
  repeatDelay: 1,
  transformStyle: "preserve-3d",
  yoyo: true  
})
//tl.pause();

Comments