Pen Settings



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


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


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.


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.


                <svg id="svg" viewBox="0 0 400 400">

    <circle class="handle" r="10" />
    <circle class="marker" r="4" />    
  <polygon id="star" points="261,220 298,335 200,264 102,335 139,220 42,149 162,148 200,34 238,148 358,149" />  
  <g id="marker-layer"></g>
  <g id="handle-layer"></g>


                body {
  background: #e8e9e8;

#svg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;

#star {
  stroke: #29e;
  stroke-width: 20;
  stroke-linejoin: round;
  fill: none;

.handle {
  fill: #fff;
  fill-opacity: 0.4;
  stroke-width: 4;
  stroke: #fff;

.marker {
  fill: tomato;
  stroke: tomato;
  pointer-events: none;


var star = document.querySelector("#star");
var markerDef = document.querySelector("defs .marker");
var handleDef = document.querySelector("defs .handle");
var markerLayer = document.querySelector("#marker-layer");
var handleLayer = document.querySelector("#handle-layer");

var points = [];
var numPoints = star.points.numberOfItems;

for (var i = 0; i < numPoints; i++) {  
  var point = star.points.getItem(i);
  points[i] = {x:point.x, y:point.y};

TweenLite.set("#svg", { autoAlpha: 1 });

function createHandle(point) {
  var marker = createClone(markerDef, markerLayer, point);
  var handle = createClone(handleDef, handleLayer, point);
  var draggable = new Draggable(handle, {
    bounds: window,
    throwProps: true,
    onDrag: moveAction,
    onThrowUpdate: moveAction,
    throwResistance: 5000,
    liveSnap: {
      points: points,
      radius: 10
    snap: {
      points: points,
      radius: 50
  function moveAction() {
    point.x = this.x;
    point.y = this.y;

function createClone(node, parent, point) {
  var element = node.cloneNode(true);
  TweenLite.set(element, { x: point.x, y: point.y });
  return element;