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.


                <p class="text">serendipity</p>
<svg id="svg" width="400" height="300" viewbox="0 0 400 300" id="svg">
  <path id="curve" d="M10,150 Q200,150 390,150" 
        fill="none" stroke="#f52e6d" stroke-width="6"/>


                #svg {
  position: absolute;
  margin-left: -200px;
  margin-top: -150px;
  left: 50%;
  top: 50%;
  z-index: 10;
  cursor: arrow;

.text {
  width: 380px;
  height: 260px;
  position: absolute;
  margin-left: -190px;
  margin-top: -150px;
  left: 50%;
  top: 50%;
  font-size: 78px;
  line-height: 228px;
  pointer-events: none;
  z-index: 0;


                var svgElemnt, path;
var connected, tweening, tween;
var mousePos = {}, svgTop;

function init() {
  svgElement = document.getElementById('svg');
  path = document.getElementById('curve');

function setSVGTop() {
  svgTop = svgElement.getBoundingClientRect().top;

function addListeners() {
  window.addEventListener('mousemove', function(e) {
    // storing the y position of the mouse - we want the y pos relative to the SVG container so we'll subtract the container top from clientY.
  	mousePos.y = e.clientY - svgTop;
  window.addEventListener('resize', setSVGTop);
  path.addEventListener('mouseover', function() {
    // if we haven't connected yet and we're not tweening back to center, bgin connection
    if (!connected && !tweening) {
      connected = true; = 'pointer';

function updateCurve() {
  var y = mousePos.y;
  y = mousePos.y - (150-mousePos.y)*1.1;
  if (Math.abs(150-y) > 100) {
    connected = false;
    tweening = true; = 'default';
  } else {
    path.setAttribute('d', 'M10,150 Q200,'+y+' 390,150');

function snapBack(y) {
  tween = new TWEEN.Tween({ y: y })
    .to({ y: 150 }, 800)
    .easing( TWEEN.Easing.Elastic.Out )
    .onUpdate( function () {
    }).onComplete(function() {
      tweening = false;

function updatePath(y) {
  // update SVG path control point
  path.setAttribute('d', 'M10,150 Q200,'+y+' 390,150');

function loop(time) {
  if (connected) updateCurve();

window.onload = init;