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.


                  <div class="container">
    <h1>A draggable Bezier connector</h1>
    <p>Here I attempt to create a draggable cubic curve connector, similar to those seen in various compositors etc.</p>
    <p>Because it's SVG, at some later point I may also be able to apply effects to connectors based on the application state</p>
    <p>For the visual feel of what I'm trying to build, try <a href="" target="_blank">this pen</a>.</p>
    <p>This is step #1: Animating a curve based on drag-and-drop interactions. <em>Drag the circle around and see the path respond!</em></p>
    <svg width="300" height="300" class="cnv" xmlns="">
      <path d="M10 10 C 50 10, 200 250, 250 250" />
      <circle cx="250" cy="250" r="4" />
    <p><small>Some status information:</small></p>
    <pre id="mouseStatus"></pre>



                .cnv {
  display: block;
  background-color: #a0a0a0;
  margin: 0 auto;
.cnv > path {
  fill: transparent;
  stroke: #e0e0e0;
  stroke-width: 2px;
.cnv > circle {
  fill: #eaeaea;
  stroke: #505050;
  transition: 0.1s;
  cursor: pointer;
.cnv > circle.isDragging {
  transition: 0 !important;
.cnv > circle:hover {
  stroke-width: 3px;
  transition: 0.2s;

body {
  font: 15px/21px Lato, Ubuntu, sans-serif;

.container {
  max-width: 500px;
  margin: 0 auto;


                const mouseState = {
  x: 0,
  y: 0,
  isDown: false,
  isDragging: false

const sd = document.querySelector('#mouseStatus')
const cnv = document.querySelector('.cnv')
const circ = cnv.querySelector('circle')
circ.draggable = false
const path = cnv.querySelector('path')

function setMouseState(ns) {
  if ('isDown' in ns) {
    const e = document.elementFromPoint(
    if (e === circ || !ns.isDown) {
      ns.isDragging = ns.isDown
  Object.assign(mouseState, ns)
  sd.innerText = JSON.stringify(mouseState, null, 2)
  if (mouseState.isDragging) {
    const rc = cnv.getBoundingClientRect() = mouseState.x - rc.x = mouseState.y - rc.y
    path.pathSegList[1].x = mouseState.x - rc.x
    path.pathSegList[1].y = mouseState.y - rc.y
    path.pathSegList[1].x2 = mouseState.x - rc.x - 50
    path.pathSegList[1].y2 = mouseState.y - rc.y
  } else {

function mouseListener(f) {
  return function(e) {
    return f(e)

  mouseListener(e => setMouseState({x: e.clientX, y: e.clientY}))
  mouseListener(e => setMouseState({isDown: true}))
  mouseListener(e => setMouseState({isDown: false}))