Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="viewport-box">
  <div class="main-circle"></div>
</div>
              
            
!

CSS

              
                .debugger{
  position:absolute;
  top:0;
  right:0;
  font-size:20px;
  color:red;
}
.viewport-box{
  padding:50px;

}
.main-circle{
  width: 400px;
  height: 400px;
  background: #f4f4f4;
  position: relative;
  border-radius: 50%;
  margin: 0 auto;
}

              
            
!

JS

              
                var circle = document.querySelector(".main-circle"),
    imageURLs = ["https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/greensock-man-logo.svg","https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/greensock-man-logo.svg","https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/greensock-man-logo.svg"],
    images = placeImages(imageURLs, 100, 100), 
    spin = new TimelineMax({repeat:-1});

//rotate the circle clockwise while at the same time rotating each image counter-clockwise to make them look like they're not spinning at all. 
spin.to(circle, 60, {rotation:360, ease:Linear.easeNone})
    .to(images, 60, {rotation:-360, ease:Linear.easeNone}, 0);

//feed an array of URLs into this function and it'll place the images evenly around the edge of the circle, setting them to whatever width/height you define (in pixels)
function placeImages(imageURLs, width, height) {
  var angleIncrement = Math.PI * 2 / imageURLs.length,
      radius = circle.offsetWidth / 2,
      images = [],
      image, angle, i;
  for (i = 0; i < imageURLs.length; i++) {
    image = new Image();
    images.push(image);
    image.setAttribute("src", imageURLs[i]);
    circle.appendChild(image);
    angle = angleIncrement * i;
    TweenLite.set(image, {
      width:width, 
      height:height, 
      position:"absolute", 
      top:0, 
      left:0, 
      xPercent:-50, 
      yPercent:-50,
      transformOrigin:"50% 50%",
      x: radius + Math.cos(angle) * radius,
      y: radius + Math.sin(angle) * radius
    });
  }
  return images;
}
 
Draggable.create('.main-circle', {
    type: 'rotation',
    throwProps:true,
    onPressInit: function(){
      spin.pause();
    },
    onDrag:function() {
      //just convert the rotation into a progress value for the spin timeline. Easy peasy. Very performant too. 
      var angle = (this.rotation + 360 * 100000) % 360; //ensure that the value is always between 0 and 360. Don't let it go negative or beyond 360. 
      spin.progress(angle/360);
    },
    onThrowUpdate: function(){
      var angle = (this.rotation + 360 * 100000) % 360;
      spin.progress(angle/360);
    },
    onThrowComplete: function() {
      spin.resume();
      //ease back into the normal spin by tweening the timeScale from 0 to 1
      TweenLite.fromTo(spin, 1, {timeScale:0}, {timeScale:1, ease:Power1.easeIn});
    }
});


              
            
!
999px

Console