Pen Settings

HTML

CSS

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

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

              
                <body style="background:#fff">
  <!-- Simple SVG and GreenSock animated hourglass spinner -->
  <!-- by @Bangkokian --->
  <!-- Set the sand speed and flip speed at the top of the .js -->
  
  <div style="width:75px; height:86px;margin:auto;margin-top:60px;overflow:visible;opacity:.4">
  <svg id= "hgmain" width="75px" height="86px" viewBox="0 0 75 86" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">
    <g id="Capa_1" transform="matrix(0.247861,0,0,0.247861,-5.54316,0.038877)">
        <g >
            <path d="M324.658,20.572L324.658,17.634C324.658,7.935 316.724,0 307.025,0L40.313,0C30.614,0 22.678,7.935 22.678,17.634L22.678,20.572C22.678,30.271 30.613,38.206 40.313,38.206L47.127,38.206C50.627,38.206 50.35,41.473 50.35,43.143C50.35,62.731 58.381,85.374 64.536,99.841C76.88,128.853 104.983,152.654 128.052,169.46C132.263,172.528 131.253,175.376 128.808,177.335C106.433,195.259 77.015,218.167 64.537,247.495C58.478,261.734 50.603,283.895 50.357,303.267C50.332,305.254 51.128,309.129 46.378,309.129L40.314,309.129C30.615,309.129 22.679,317.065 22.679,326.763L22.679,329.703C22.679,339.401 30.614,347.337 40.314,347.337L307.027,347.337C316.726,347.337 324.66,339.401 324.66,329.703L324.66,326.763C324.66,317.065 316.726,309.129 307.027,309.129L303.211,309.129C296.211,309.129 296.885,303.888 296.957,301.171C297.445,283.077 292.125,262.498 284.34,247.036C267.022,212.647 239.711,190.775 222.891,178.121C219.241,175.376 218.873,171.978 222.891,169.215C240.233,157.286 267.022,134.689 284.34,100.299C292.629,83.835 298.125,61.567 296.787,42.678C296.682,41.164 296.576,38.206 300.545,38.206L307.027,38.206C316.725,38.206 324.658,30.272 324.658,20.572ZM270.271,93.216C254.158,125.214 228.304,148.097 205.816,161.886C204.462,162.717 201.88,164.767 201.88,170.488L201.88,177.326C201.88,183.392 204.632,184.723 206.079,185.612C228.565,199.418 254.222,222.248 270.27,254.12C277.684,268.847 281.536,286.652 281.155,300.822C281.077,303.769 282.208,309.13 274.542,309.13L72.627,309.13C65.877,309.13 66.152,305.76 66.168,303.917C66.285,291.022 70.731,273.16 79.027,253.662C93.431,219.808 123.656,198.674 143.777,186.085C144.673,185.524 146.406,184.518 146.406,179.163L146.406,168.927C146.406,163.393 143.75,161.239 142.349,160.357C122.251,147.669 93.093,126.739 79.027,93.676C70.644,73.974 66.193,55.944 66.166,43.019C66.164,41.325 66.377,38.207 70.127,38.207L276.709,38.207C280.877,38.207 280.836,41.357 280.973,43.036C282.156,57.681 278.307,77.257 270.271,93.216Z" style="fill:rgb(17,101,255);fill-rule:nonzero;"/>
        </g>
    </g>
    <g transform="matrix(1.51297,-3.01323e-16,1.9916e-16,1,-21.931,22.9882)">
        <g id="hgsand1">
            <path d="M39.281,20.694L53.996,50.124L24.566,50.124L39.281,20.694Z" style="fill:rgb(44,175,227);"/>
        </g>
    </g>
    <g transform="matrix(-1.51297,4.86608e-16,-3.21625e-16,-1,96.931,63.8067)">
        <g id="hgsand2">
            <path d="M39.281,20.694L53.996,50.124L24.566,50.124L39.281,20.694Z" style="fill:rgb(44,175,227);"/>
        </g>
    </g>
</svg>
  </div>
</body>

              
            
!

CSS

              
                
              
            
!

JS

              
                // NOTE: 3 SVG id's:
// hgmain
// hgsand1
// hgsand2

var hgssandspeed = 2;
var hgflipspeed = .5;

function hgFirstWay() {
    sandtop = document.getElementById("hgsand2");
    //sandtop.style.transformOrigin = "-17% -35%";
    TweenMax.set(sandtop,{transformOrigin:"50% 50%"}); /* GSAP set() transformOrigin to center */

    sandbottom = document.getElementById("hgsand1");
    //sandbottom.style.transformOrigin = "-17% 20%";
    TweenMax.set(sandbottom,{transformOrigin:"50% 50%"}); /* GSAP set() transformOrigin to center */
    TweenMax.to(sandbottom,0,{scale:0}); // preset bottom to invisible

    TweenMax.to(sandtop,hgssandspeed,{scale:0, ease:Linear.easeIn});
    TweenMax.to(sandbottom,hgssandspeed,{scale:1, ease:Linear.easeOut, onComplete:hgRotate});
}


function hgRotate() {
    theglass = document.getElementById("hgmain");
    //theglass.style.transformOrigin = "50% 50%";
    TweenMax.set(theglass,{transformOrigin:"50% 50%"}); /* GSAP set() transformOrigin to center */
    TweenMax.to(theglass,hgflipspeed,{rotation:180,ease:Quad.easeInOut, onComplete:hgSecondWay})
}

function hgSecondWay() {
    sandtop = document.getElementById("hgsand1");
    //sandtop.style.transformOrigin = "-17%  -75%";
    TweenMax.set(sandtop,{transformOrigin:"50% 50%"}); /* GSAP set() transformOrigin to center */

    sandbottom = document.getElementById("hgsand2");
    //sandbottom.style.transformOrigin = "-17% 70%";
    TweenMax.set(sandbottom,{transformOrigin:"50% 50%"}); /* GSAP set() transformOrigin to center */

    TweenMax.set(sandbottom, {scale:0}); // preset bottom to invisible

    TweenMax.to(sandtop,hgssandspeed,{scale:0, ease:Linear.easeOut});
    TweenMax.to(sandbottom,hgssandspeed,{scale:1, ease:Linear.easeIn, onComplete:hgRotateAgain});
}

function hgRotateAgain() {
  theglass = document.getElementById("hgmain");
  //theglass.style.transformOrigin = "50% 50%";
  TweenMax.set(theglass,{transformOrigin:"50% 50%"}); /* GSAP set() transformOrigin to center */
  TweenMax.to(theglass,hgflipspeed,{rotation:0,ease:Quad.easeInOut, onComplete:hgFirstWay})
}

hgFirstWay();

              
            
!
999px

Console