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

              
                <main>
  <a href="https://github.com/creativewave/animate" target="_blank">
    <svg viewBox="0 0 16 16">
      <path fill="#fff" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" />
    </svg>
  </a>
  <svg id=scene viewBox="0 0 50 50">
    <defs>
      <g id=pacman>
        <path d="M2 0C2 1.104 1.104 2 0 2-0.88 2-1.628 1.432-1.895 0.642 0 0-1.895 0.642 0 0-1.884-0.673 0 0-1.884-0.673-1.607-1.446-0.868-2 0-2 1.104-2 2-1.104 2 0z"/>
        <circle cx="-0.5" cy="-1.1" r="0.3"/>
      </g>
      <g id=monster>
        <path d="M-2 0a2 2 0 014 0v1.3a.7.7 0 01-1.35.25.7.7 0 01-1.3 0A.7.7 0 01-2 1.3V0z"/>
        <circle cx="-1" r=".5"/>
        <circle cx="-1.15" cy=".1" r=".25"/>
        <circle cx=".8" r=".5"/>
        <circle cx=".65" cy=".1" r=".25"/>
      </g>
    </defs>
    <path id=path d="M25 0A25 25 0 110 25h25V0z" />
    <use id=target href="#pacman" />
    <use id=target2 href="#monster" />
    <circle id=eye cx="35" cy="15" r="3"/>
  </svg>
</main>
              
            
!

CSS

              
                
* {
  box-sizing: border-box
}

body {
  background-color: #0c1419;
}

main {
  position: relative;
  display: grid;
  height: 100vh;
  overflow: hidden;
  justify-content: center;
  align-content: center;
}

main a {
  position: absolute;
  top: -4rem;
  right: -4rem;
  width: 8rem;
  height: 8rem;
  padding: 1rem;
  overflow: visible;
  background-color: #2e404d;
  border-radius: 50%;
  transition: background-color 300ms ease;
}
main a:hover {
  background-color: #73b6e6;
}

main a svg {
  width: 2rem;
  height: 2rem;
  transform: translate(0.5rem, 3.5rem);
}

svg#scene {
  width: 80vw;
  max-height: 80vh;
  overflow: visible !important;
}

#path {
  fill: #292714;
  stroke: #fff;
  stroke-width: 0.3;
  stroke-dasharray: 0.1 1;
  stroke-linecap: round;
}

#pacman {
  transform: rotate(180deg)
}

#pacman path {
  fill: #fcee21;
  animation: mouth 200ms infinite;
}

#eye {
  fill: #0c1419;
}

#monster path {
  fill: #ed1c24;
}
#monster.destroy path {
  animation: destroy 1s;
}

#monster circle:nth-of-type(odd) {
  fill: #fff;
}
#monster circle:nth-of-type(even) {
  fill: #00f;
}

@keyframes mouth {
  to {
    d: path('M2 0C2 1.104 1.104 2 0 2-0.88 2-2 1.297-2 0-1 0-1 0 0 0-1 0-1 0-2 0-2-1.4-0.868-2 0-2 1.104-2 2-1.104 2 0z');
  }
}

@keyframes destroy {
  12%, 36%, 60%, 84% {
    opacity: 0;
  }
  24%, 48%, 72%, 86% {
    opacity: 1;
  }
}
              
            
!

JS

              
                
const options = { duration: 4000, fill: 'forwards' }

const animation1 = animate.default(target, path, { ...options, delay: 100, rotate: true })
const animation2 = animate.default(target2, path, options)

animation1.onfinish = () => {
  monster.classList.toggle('destroy')
  setTimeout(() => {
    animation1.play()
    animation2.play()
    monster.classList.toggle('destroy')
  }, 500)
}
              
            
!
999px

Console