css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="title"><h1>GSAP BezierPlugin</h1></div>

<div class="container">
  <img class="bee" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/bee-character.svg" alt="bee">

<div class="controls">
  <select class="dropown" id="curviness">
    <option value="">Curviness Values</option>
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="1.5">1.5</option>
    <option value="2">2</option>
    <option value="2.5">2.5</option>
  <label for="rotate">
    <input type="checkbox" id="rotate"> autoRotate
  <label for="type-thru">
    <input type="radio" id="type-thru" name="type"> Thru
  <label for="type-soft">
    <input type="radio" id="type-soft" name="type"> Soft
              * {
  box-sizing: border-box;

body {
  font-family: sans-serif;

.title {
  padding: 0.5em;
  width: 100%;
  margin: 0 auto;
  text-align: center;
  font-size: 0.8rem;

.container {
  max-width: 600px;
  height: 600px;
  margin: 0 auto;
  margin-bottom: 50px;
  position: relative;
  overflow: hidden;
  background: green url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/flowers.svg) center center no-repeat;
  background-size: cover;
  border: 2px solid blue;
  border-radius: 25%;
  box-shadow: 0 10px 20px rgba(0, 0, 0, .5);

/* controls */
select {
  display: inline-block;
  margin-bottom: 1em;
.controls {
  width: 100%;
  max-width: 800px;
  padding: 1em;
  padding-bottom: 2em;
  margin: 0 auto;
  font-size: 1.5rem;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;

.bee {
  display: block;
  position: absolute;
  width: 100px;
  height: 100px;
  top: 50px;
  left: 100px;

const bee = document.querySelector('.bee'),
      selectCurviness = document.querySelector('#curviness'),
      checkRotate = document.querySelector('#rotate'),
      typeThru = document.querySelector('#type-thru'),
      typeSoft = document.querySelector('#type-soft'),
      points = [
        {x: 50, y: 50},
        {x: 110, y: 250},
        {x: 200, y: 400},
        {x: 300, y: 250},
        {x: 400, y: 400}  
      let curvinessVal = 0,
          rotate = false,
          bezierType = 'thru';

function start(type, curvinessVal, rotate) {
  //Initialize a timeline for the animation
  const tl = new TimelineMax();
  //Clear all animations and set the 
  //playhead to the beginning
  //Set an initial rotation for the element (optional)
  tl.set(bee, {
    rotation: 40 
  tl.to(bee, 5, {
      bezier: { //BezierPlugin properties
        curviness: curvinessVal,
        type: type,
        values: points,
        autoRotate: rotate
      ease: Circ.easeInOut //Animation easing

//Call the start()function to start the animation
start(bezierType, curvinessVal, rotate);

//Listen for the change event of the dropdown box
selectCurviness.addEventListener('change', function() {
  //If the selected index of the select box has a value
  if(this.options[this.selectedIndex].value) {
    //set the curviness value to that of the 
    //select box
    curvinessVal = this.options[this.selectedIndex].value;   
  } else {
    //Otherwise the curviness value remains unchanged
    curvinessVal = curvinessVal;
  //Call the start()function to see the animation
  //using the selected value
  start(bezierType, curvinessVal, rotate); 

//Listen for the change event of the autoRotate checkbox
checkRotate.addEventListener('change', function() {
  //if the checkbox is checked, set the 
  //rotate variable to true, otherwise set it to false
  if(checkRotate.checked) {
    rotate = true;
  } else {
    rotate = false;  
  //Call the start()function to animate the element
  start(bezierType, curvinessVal, rotate); 

//Listen for the change event on the radio button 
//to set the value for the soft property
typeSoft.addEventListener('change', function() {
  //When the button is selected, disable the 
  //select box for the curviness property
  //and reset it to 0
  selectCurviness.disabled = true;
  selectCurviness.selectedIndex = 0;
  selectCurviness.options[selectCurviness.selectedIndex].value = 0;
  curvinessVal = 0;
  //Call the start() function to begin the animation
  start(bezierType, curvinessVal, rotate);

//Listen for the change event on the radio button 
//to set the thru value for the type property
typeThru.addEventListener('change', function() {
  //If thru is selected, enable the select box for 
  //the curviness property 
  selectCurviness.disabled = false;
  //Call the start()function to animate the element
  start(bezierType, curvinessVal, rotate);

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................