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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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.


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.

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.


    <path id="arrow" d="M0,0 l-10,12 h6 v40 h8 v-40 h6 z" stroke="none" fill="black" />
  <circle id="circle" r="6" fill="red" stroke="black" stroke-width="1" />  
  <line id="line1" stroke="red" stroke-width="2" />
  <line id="line2" stroke="black" />


                svg {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;


var vw = window.innerWidth;
var vh = window.innerHeight;

var svg = document.querySelector("svg");
var arrow = document.querySelector("#arrow");
var circle = document.querySelector("#circle");

var x1 = random(100, vw - 100);
var y1 = random(100, vh - 100);

var speed = 600; // Pixels/seconds

TweenLite.set(circle, { x: x1, y: y1 });

svg.addEventListener("click", addArrow);

function addArrow(event) {
  var tl = new TimelineMax({ repeat: -1, repeatDelay: 0.25 });
  var x2 = event.clientX;
  var y2 = event.clientY;
  var dx = x1 - x2;
  var dy = y1 - y2;
  var dist = Math.sqrt(dx * dx + dy * dy);  
  var angle = Math.atan2(dy, dx) - (Math.PI / 2);
  var clone = arrow.cloneNode(true);
  var ratio = dist / speed;
  TweenLite.set(clone, {
    transformOrigin: "center top",
    rotation: angle + "rad",
    autoAlpha: 0,
    scale: 0,
    x: x1,
    y: y1,
  tl.set(clone, { autoAlpha: 1 })
    .to(clone, 1 * ratio, { scale: 1 }, 0)
    .to(clone, 2 * ratio, { x: x2, y: y2 }, 0)
    .to(clone, 0.25, { autoAlpha: 0 }, "+=0.5");

function random(min, max) {
  if (max == null) { max = min; min = 0; }
  return Math.random() * (max - min) + min;