Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <div class="container js-container">
  <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin slice">
    <circle class="origin js-origin" cx="45" cy="45" r="25"/>    
    
    <!-- first keyframes -->
    <path class="js-keyframe-1-1" d="M26.3-12.2c6.4-9.7,11.4-1.8,50.9-6.1s82.5-4.4,100,1.8s14.9,3.5,34.2,26.3s22.8,27.2,27.2,56.1s17.5,65.8-7,101.8s-42.4,89.3-89.8,100.7s-64.6-7.8-96.2-24.4S-0.9,227.3-14,199.2s-26.3-20.2-14-61.4S-13.1,79.9-16.6,65s-16.7-26.3-1.8-41.2S-6,13.2,11.4,0.1C18.4-5.2,19.9-2.5,26.3-12.2z"/>
    
    <path class="js-keyframe-1-2" d="M23.2-24.1c7.2-10.8-6.2-36,37.9-40.9s68.1,69.5,87.7,76.3c19.6,6.9,59.5-36.4,81.1-11s25.5,30.4,30.4,62.7s-23.5,53.7-50.9,93.9c-27.4,40.2-4.3,119.5-57.2,132.2c-52.9,12.7-47.9-44.3-83.2-62.9c-35.3-18.6-76.1,17-90.8-14.3s-29.4-22.5-15.7-68.6c13.7-46-7.1-59.2-11-75.9s5.2-34.8,21.8-51.4s-15.9-16.4,3.6-31C-15.3-20.8,16.1-13.3,23.2-24.1z"/>
    
    <path class="js-keyframe-1-3" d="M143.9-37.5c12.1-2.4,9.9,7.3,43,33.7c33.1,26.4,65.5,58.8,74.1,76.7c8.6,17.9,8.6,13.9,6,45.6c-2.6,31.7-3.3,37.7-21.8,62.8s-36.4,62.8-82,71.4c-45.6,8.6-99.3,35.4-143.6,8.3c-44.3-27.1-42.9-54.6-54.1-90.9c-11.2-36.4-22.5-47.6-11.2-78.7c11.2-31.1-4.6-35,35.7-56.9C30.1,12.7,44.7,2.1,53.3-11.7c8.6-13.9,7.3-32.4,29.8-32.4c22.5,0,17.3,1.3,40.3,4.6C132.6-38.2,131.7-35.1,143.9-37.5z"/>
    
    <!-- second keyframes -->
    <path class="js-keyframe-2-1" d="M-20.5-85.1c9.9-14.9,23.3-37.1,84.2-43.9c60.9-6.8,110.6-20,137.7-10.5c27.1,9.5,290.4-55.4,320.2-20.2
	c29.8,35.2,166,302.7,172.8,347.4c6.8,44.7-47.4,230.7-98.2,272.8c-51.8,42.9-386.5,113.1-459.6,130.7C63.5,608.8,58.1,404.6,9.4,378.9c-48.7-25.7-46.8-55.3-67.1-98.7c-20.3-43.3-40.6-31.1-21.7-94.8c19-63.6,23-89.4,17.6-112.4c-5.4-23-55.4-47.5-32.3-70.5c23-23,17.8-29.8,44.7-50C-38.6-55.5-30.4-70.2-20.5-85.1z"/>
   
    <path class="js-keyframe-2-2" d="M242.4-222.1c16.2-3.3,39.5-9,83.7,26.4c44.2,35.4,85.4,59.2,96.9,83.1C434.5-88.7,649,41,645.5,83.5
	c-3.5,42.5-89.3,306.4-114.1,340c-24.8,33.6-181.7,119.8-242.5,114.1C227,531.7-37.7,358.8-97,322.6c-59.3-36.3,70.7-173.2,55.6-221.9C-56.4,52-35.8,33.9-20.7-7.7c15-41.6-6.2-46.9,47.8-76.1c54-29.2,73.4-43.4,84.9-61.9c11.5-18.6-5.1-67.2,24.9-67.2c30.1,0,31.1-7.8,61.9-3.4C211.3-214.6,226.2-218.9,242.4-222.1z"/>
    
    <path class="js-keyframe-2-3" d="M-104.4-4c4.6-17.3,10.2-42.6,65.8-68.5c55.6-25.9,98.4-54.3,127.1-54c28.7,0.3,257.4-145.3,296.9-121.5
	C424.8-224.1,639.5-14.2,660.2,26c20.7,40.2,28.9,233.7-5.9,289.9C618.9,373,324.2,546.6,260.6,586.7c-63.6,40-134-151.7-188.4-160.5c-54.4-8.8-62-37.5-95.1-72c-33.1-34.6-48.4-16.5-50.8-82.9c-2.4-66.4-6.8-92-19.2-112.1c-12.5-20.1-67.6-27.3-53.2-56.5c14.5-29.2,7.3-33.9,26.4-61.7C-112.2,29.9-109.1,13.3-104.4-4z"/>
    
    <!-- third keyframes -->
    <path class="js-keyframe-3-1" d="M-49.4-143.9c13.6-20.4,38.8-21.5,121.9-30.7c83.2-9.2,106-36.6,143-23.7c37,12.9,211.1-100.7,251.8-52.6c40.7,48.1,504.8,186.4,514,247.4c9.2,61,95.6,344.4,43.9,420.2c-51.8,75.8-460.7,204.9-560.5,228.9c-99.8,24-478.2,9.7-544.7-25.4c-66.5-35.1,12.8-226-15-285.1c-27.7-59.1-146-45.6-120.1-132.4c25.9-86.9,36.3-120.3,28.9-151.8c-7.4-31.4,1.9-63.3,33.3-94.7c31.4-31.4,21.1-26.8,57.9-54.4C-80.2-109.4-62.9-123.6-49.4-143.9z"/>
    
    <path class="js-keyframe-3-2" d="M54.1-307.7c21.5-15.2,47.3-6.6,134.5,16.4c87.2,22.9,120.8,4.3,152.9,31.6c32.1,27.3,251.2-19.4,273.5,44.6c22.3,64.1,435.2,383,420.9,447.9c-14.3,64.9-37.3,383.3-118.7,439.4c-81.4,56.1-542.5,27.5-652.2,13c-109.6-14.5-484.5-175.6-537.7-236.7c-53.3-61.1,100.4-222.2,95.4-292.4c-5-70.2-129.1-102.4-69.4-179.7c59.7-77.3,83.2-106.9,87.9-141.3c4.7-34.5,26.5-62.9,70.2-82.3c43.8-19.4,31.6-18.8,79.3-32.2C9.8-284.9,32.7-292.5,54.1-307.7z"/>
    
    <path class="js-keyframe-3-3" d="M440.5-430.4c26.3,1,41.5,23.5,96.8,94.8c55.3,71.2,93.3,76.8,102.2,118.1c8.9,41.2,211.2,137.3,190,201.7c-21.3,64.4,112.6,568.7,61.8,611.5S628.5,877.2,529.8,872.3C431.1,867.3,82.4,564.2,4.2,486c-78.2-78.2-277.8-434-283-514.9C-284-109.8-64-144.3-25.3-203c38.8-58.7-40.3-159.8,54.1-184.9c94.4-25.1,131-34.3,155.7-58.8c24.7-24.5,59.3-33.9,105.8-22.7s36.5,4.3,82.5,22.6C391.4-439.3,414.2-431.4,440.5-430.4z"/>
  </svg>
</div>
              
            
!

CSS

              
                body {
  background: black;
}

.container {
  background: url(https://unsplash.it/1920/1080?image=1025) 50% 50%;
  background-size: cover;
  height: 720px;
  position: relative;
  width: 1280px;
  
  &:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(#000,.2);
    z-index: -1;
  }

  svg { 
    width: 100%;
    height: 100%;
    transform: scaleY(-1);
    
    circle, path {
      fill: none;
      stroke: #fff;          
      stroke-dasharray: 3 3;
      visibility: hidden;      
    }    
  }
}
              
            
!

JS

              
                var $container = $('.js-container');
var $origin = $container.find('.js-origin');
var mainTL = new TimelineLite({ paused: true });

// keyframe shapes
var $firstKeyframes = $container.find('[class^="js-keyframe-1"]');
var $secondKeyframes = $container.find('[class^="js-keyframe-2"]');
var $thirdKeyframes = $container.find('[class^="js-keyframe-3"]');

function getRandomIntFromInterval(min, max) {
  return Math.floor(Math.random()*(max-min+1)+min);
}

function getRandomKeyframes() {
  var firstKeyframeIndex = getRandomIntFromInterval(0, $firstKeyframes.length - 1);
  var secondKeyframeIndex = getRandomIntFromInterval(0, $secondKeyframes.length - 1);
  var thirdKeyframeIndex = getRandomIntFromInterval(0, $thirdKeyframes.length - 1);
    
  return {
    firstKeyframe: $firstKeyframes.get(firstKeyframeIndex),
    secondKeyframe: $secondKeyframes.get(secondKeyframeIndex),
    thirdKeyframe: $thirdKeyframes.get(thirdKeyframeIndex)
  }
}

function checkForNewAnimation() {
  // todo: check for active audio player  
  console.log('checkForNewAnimation');
  addNewAnimation();
}

function getAnimation(originKeyframe) {
  var animation = new TimelineLite();
  var randomKeyframes = getRandomKeyframes();
  
  var firstKeyframe = randomKeyframes.firstKeyframe;
  var secondKeyframe = randomKeyframes.secondKeyframe;
  var thirdKeyframe = randomKeyframes.thirdKeyframe;
  
  console.info(
    $(firstKeyframe).attr('class'),
    $(secondKeyframe).attr('class'),
    $(thirdKeyframe).attr('class')
  );

  animation.eventCallback('onComplete', function() {
    console.log('animation complete'); 
    // this.kill();
    // todo: remove this child animation after complete
  });

  animation
    .fromTo(originKeyframe, 2, { autoAlpha: 0 }, { autoAlpha: 1 })
    .to(originKeyframe, 2, { morphSVG: firstKeyframe, ease: Power0.easeNone })
    .call(checkForNewAnimation)
    .to(originKeyframe, 5, { morphSVG: secondKeyframe, ease: Power0.easeNone })
    .to(originKeyframe, 3, { morphSVG: thirdKeyframe, autoAlpha: 0, ease: Sine.easeOut });

  return animation;
}

function addNewAnimation() {
  var originShape = MorphSVGPlugin.convertToPath($origin);
  var currentTime = mainTL.time();
  
  console.log(currentTime);
  
  mainTL.add(getAnimation(originShape), currentTime);
}

function initMainTL() {      
  mainTL.eventCallback('onStart', function() {
    console.log('start');
  });
  
  mainTL.eventCallback('onComplete', function() {
    console.log('mainTL complete');
  });

  addNewAnimation();
  
  return mainTL;
}

initMainTL().play();

              
            
!
999px

Console