cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div id="svg-container">
  <?xml version="1.0" encoding="utf-8"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
  <svg xmlns="http://www.w3.org/2000/svg" width="190" height="160" viewBox="0 0 190 160">
    <path fill="none" stroke="#000000" d="M10 80 Q 52.5 10, 95 80 T 180 80"/>
    <circle r="8" cx="0" cy="0" fill="slategrey">
  </svg>
</div>
            
          
!
            
              html,body{
  height: 100%;
}
#svg-container{
  height: 100%;
  text-align: center;
  &:before{
    content: '';
    display: inline-block;
    vertical-align: middle;
    width: 0;
    height: 100%;
  }
}
svg{
  display: inline-block;
  vertical-align: middle;
  circle{
    &.show{
      opacity: 1;
    }
  }
}

            
          
!
            
              var $circle = $('svg').find('circle');
var $path = $('svg').find('path');
var progress = 0;
var distance = $path.get(0).getTotalLength();
var animTimer;

var duration = 2000;
var elapsedTime = 0;
var frame = 30;

// t: current time, b: begInnIng value, c: change In value, d: duration
var easeOutCubic = function (x, t, b, c, d) {
  return c*((t=t/d-1)*t*t + 1) + b;
}

var anim = function(){
  animTimer = setTimeout(function(){
     if(elapsedTime < duration){
        progress = easeOutCubic(1, elapsedTime, 0, distance, duration);
        var _point = $path.get(0).getPointAtLength(progress);
        $circle.attr( 'transform' , 'translate(' + _point.x + ',' + _point.y + ')');
        elapsedTime += frame; 
        anim();
     }else{
         clearTimeout(animTimer);
         progress = 0;
         elapsedTime = 0;
         setDefault();
         anim();
     }
 }, frame);
}

var setDefault = function(){
  var _zero = $path.get(0).getPointAtLength(0);
  $circle.attr('transform', 'translate(' + _zero.x + ',' + _zero.y + ')').addClass('show');
}

var init = (function(){
  setDefault();
  anim();
})();
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console