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 Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

                    <svg id="Dance" width="100%" height="100%" viewBox="-37.5 -200 225 500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      <clipPath id="Blink">
        <path d="M100,175 L0,175 L0,25 C0,52.6142375 22.3857625,75 50,75 C77.6142375,75 100,52.6142375 100,25 L100,175 Z" id="BlinkShapeBottom"></path>
        <path d="M100,175 L0,175 L0,25 C0,52.6142375 22.3857625,75 50,75 C77.6142375,75 100,52.6142375 100,25 L100,175 Z" id="BlinkShapeTop"></path>
    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <g id="Artboard-1" transform="translate(-175.000000, -200.000000)">
            <g id="Creature" transform="translate(175.000000, 200.000000)">
                <path d="M150,225 C150,183.578644 116.421356,150 75,150 C33.5786438,150 0,183.578644 0,225 L0,300 C0,341.421356 33.5786438,375 75,375 C116.421356,375 150,341.421356 150,300 L150,225 Z" id="CreatureBase" fill="#000000"></path>
                <circle id="CreatureMiddle" fill="#000000" cx="75" cy="188" r="75"></circle>
                <g id="CreatureHead" transform="translate(75.000000, 0.000000)">
                    <path d="M150,75 C150,33.5786438 116.421356,0 75,0 C33.5786438,0 0,33.5786438 0,75 L0,150 C0,191.421356 33.5786438,225 75,225 C116.421356,225 150,191.421356 150,150 L150,75 Z" fill="#000000"></path>
                    <g id="CreatureEye" transform="translate(25.000000, 25.000000)">   
                        <path d="M50,100 C77.6142375,100 100,77.6142375 100,50 C100,22.3857625 77.6142375,0 50,0 C22.3857625,0 0,22.3857625 0,50 C0,77.6142375 22.3857625,100 50,100 Z" id="CreatureEyeWhite" fill="#FFFFFF"></path>
                        <path d="M50,85 C69.3299662,85 85,69.3299662 85,50 C85,30.6700338 69.3299662,15 50,15 C30.6700338,15 15,30.6700338 15,50 C15,69.3299662 30.6700338,85 50,85 Z" id="CreatureEyeIris" fill="#000000"></path>
                        <path d="M68,44 C74.627417,44 80,38.627417 80,32 C80,25.372583 74.627417,20 68,20 C61.372583,20 56,25.372583 56,32 C56,38.627417 61.372583,44 68,44 Z" id="CreatureEyeShine" fill="#FFFFFF"></path>  
                  <g clip-path="url(#Blink)">
                    <circle id="EyeLid" cx="75" cy="75" r="55" fill="#000000"></circle>
              body {
  background-color: #00095F;

svg {
  position: absolute;
  bottom: 0;
              // get the SVG elements we want to animate
var head = document.getElementById("CreatureHead"),
    middle = document.getElementById("CreatureMiddle"),
    eye = document.getElementById("CreatureEye"),
    blinkShapeBottom = document.getElementById("BlinkShapeBottom"),
    blinkShapeTop = document.getElementById("BlinkShapeTop");

// controls the shaking movement of the head
var shake = new TimelineMax({repeat: -1});
shake.set(head, {x: "75"})
shake.to(head, 1.5, {x: "-=150", ease:Back.easeOut.config(3)});
shake.to(head, 1.5, {x: "+= 150", ease:Back.easeOut.config(3)});

// controls the shaking movement of the middle section
var follow = new TimelineMax({repeat: -1});
follow.set(middle, {x: "37.5"});
follow.to(middle, 1.5, {x: "-=75", ease:Back.easeOut.config(1.7)});
follow.to(middle, 1.5, {x: "+= 75", ease:Back.easeOut.config(1.7)});

// controls the blinking
var blinkBottom = new TimelineMax({repeat:-1});
blinkBottom.set(blinkShapeBottom, {rotation:0, y:"+=110", x:"+=25"});
blinkBottom.to(blinkShapeBottom, .75, {y:"-=110", delay:5});
blinkBottom.to(blinkShapeBottom, .75, {y:"+=100", delay:.5});

var blinkTop = new TimelineMax({repeat:-1});
blinkTop.set(blinkShapeTop, {rotation:180, y:"-=150", x:"+=25", transformOrigin:"center"});
blinkTop.to(blinkShapeTop, .75, {y:"+=110", delay:5});
blinkTop.to(blinkShapeTop, .75, {y:"-=100", delay:.5});

/*var blink = new TimelineMax({repeat:-1});
//blink.add( blinkBottom );
//blink.add( blinkTop );

// rotate the eye to simulate looking around
var look = new TimelineMax({repeat: -1});
var angle = 0;
TweenMax.set(eye, {x:"25", y:"25"});
TweenMax.to(eye, .5, {rotation:angle, transformOrigin:"center", onComplete:rotateAngle, delay:_.random(0, 3)});

function rotateAngle() {
  angle += _.random(-120, 120);
  angle = angle % 360;
  TweenMax.set(eye, {x:"25", y:"25"});
  TweenMax.to(eye, .5, {rotation:angle, transformOrigin:"center", onComplete:rotateAngle, delay:_.random(1, 3)});

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................