123

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <header class="body-header" id="body-header">
    <div class="hgroup">
        <h1>Material In a Liquid State w/ Velocity.js</h1>
        <h2>Based on the <a href="https://dribbble.com/shots/2173582-Material-In-a-Liquid-State" target="_blank">Dribble Shot</a> by Soheil Behnezhad</h2>
        <h3>Click to Toggle. Best viewed with left/right justified editors</h3>
    </div>
</header>
<main class="main">
    <nav class="toggles" id="toggles">
        <button class="nav-item">
            <svg width="36" heigt="36" viewBox="0 0 18 18">
                <path fill="#fff" d="M8 6.83V12c0 .552.448 1 1 1s1-.448 1-1V6.83c1.165-.413 2-1.524 2-2.83 0-1.657-1.343-3-3-3S6 2.343 6 4c0 1.306.835 2.417 2 2.83zM16 7h-2c-.552 0-1 .448-1 1s.448 1 1 1h.5c.276 0 .5.224.5.5v5c0 .276-.224.5-.5.5h-11c-.276 0-.5-.224-.5-.5v-5c0-.276.224-.5.5-.5H4c.552 0 1-.448 1-1s-.448-1-1-1H2c-.552 0-1 .448-1 1v8c0 .552.448 1 1 1h14c.552 0 1-.448 1-1V8c0-.552-.448-1-1-1z"
                />
            </svg>
        </button>
        <button class="nav-item">
            <svg width="36" heigt="36" viewBox="0 0 18 18">
                <path fill="#fff" d="M14.312 9c.695 0 1.3-.478 1.46-1.154l1.18-4.982C17.19 1.917 16.472 1 15.497 1H2.003c-.552 0-1 .448-1 1s.45 1 1 1h1v8.5c0 .83.67 1.5 1.5 1.5h10.495c.552 0 1-.448 1-1s-.448-1-1-1H5.002V9h9.31zm-9.31-6h9.863l-.948 4H5.002V3zm.5 11c-.828 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm7.996 0c-.828 0-1.5.67-1.5 1.5s.672 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"
                />
            </svg>
        </button>
        <button class="nav-item">
            <svg width="36" heigt="36" viewBox="0 0 18 18">
                <path fill="#fff" d="M17 3h-4V2c0-.552-.448-1-1-1H6c-.552 0-1 .448-1 1v1H1c-.552 0-1 .448-1 1v8c0 .552.448 1 1 1h2v3c0 .552.448 1 1 1h10c.552 0 1-.448 1-1v-3h2c.552 0 1-.448 1-1V4c0-.552-.448-1-1-1zm-4 12H5v-4h8v4zm3-4.5c0 .276-.224.5-.5.5H15v-1c0-.552-.448-1-1-1H4c-.552 0-1 .448-1 1v1h-.5c-.276 0-.5-.224-.5-.5v-5c0-.276.224-.5.5-.5h13c.276 0 .5.224.5.5v5z"
                />
            </svg>
        </button>
        <button class="toggle" id="toggle">
            <span class="icon"></span>
        </button>
    </nav>
</main>
<div class="action" id="action"></div>
<svg>
    <defs>
        <filter id="goo">
            <feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
            <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 18 -7" result="goo" />
            <feBlend in="SourceGraphic" in2="goo" />
        </filter>
    </defs>
</svg>
            
          
!
            
              $body-bg: #29313e;
$action: #2d394d;
$paper: #3e72dc;
$white: #fff;
$container: 800px;

body {
    background-color: $body-bg;
    font-family: 'Roboto', sans-serif;
}

html,
body {
    overflow: hidden;
}

*,
*:before,
*:after {
    backface-visibility: hidden;
}

.body-header {
    color: $white;
    margin: 0.5em auto;
    max-width: $container;
    position: relative;
    z-index: 5;
    
    .hgroup {
        left: 0;
        position: absolute;
        top: 0;
        
        @media screen and (max-width: 830px) {
            left: 15px;
        }
    }
    
    h1 {
        font-size: 1.8em;
        margin-bottom: 0.3em;
    }
    
    h2,
    h3 {
        font-size: 1em;
        margin-bottom: 0.3em;
    }
    
    a {
        color: complement($paper);
    }
}

.main {
    min-height: 100vh;
    margin: 0 auto;
    max-width: $container;
    position: relative;
}

button {
    @include square(80px);
    background-color: $paper;
    border: 0;
    border-radius: 50%;
    bottom: 40px;
    cursor: pointer;
    left: 0;
    position: absolute;
    z-index: 1;
    
    &:focus {
        outline: 0;
    }
    
    svg {
        @include center;
        @include square(36px);
    }
}

.toggle {
    @include square(100px);
    transform: rotate(0);
    
    .icon {
        @include center;
        @include square(45px);
        
        &:before,
        &:after {
            @include center;
            background-color: $white;
            border-radius: 3px;
            content: '';
            display: block;
            height: 5px;
            width: 100%;
        }
        
        &:before {
            transform: translateX(-50%) translateY(-50%) rotate(90deg);
        }
    }
}

.action {
    @include square(100vw);
    background-color: $action;
    border-radius: 50%;
    position: absolute;
    bottom: 0;
    right: 0;
    transform: translate(50%, 50%) scale(0, 0);
    z-index: 0;
}

.toggles {
    filter: url('#goo');
    height: 100%;
    position: absolute;
    right: 70px;
    top: 0;
    width: 100px;
    z-index: 1;
}

.nav-item {
    left: 50%;
    transform: translateX(-50%);
}
            
          
!
            
              (function() {
    'use strict';
    var toggle, navItem, action,
        header, size,
        doc = document,
        win = window,
        durationOut = 1000,
        durationIn = 300,
        easeIn = [0.9, 0, 0.45, 1], // Inverse of Material's Swift Out
        easeOut = [0.55, 0, 0.1, 1]; // Material's Swift Out effect

    function init() {
        toggle = document.getElementById('toggle');
        navItem = document.querySelectorAll('.nav-item');
        action = document.getElementById('action');
        header = document.getElementById('body-header');
        

        Velocity.hook(action, 'translateX', '50%');
        Velocity.hook(action, 'translateY', '50%');
        Velocity.hook(action, 'scaleX', 0);
        Velocity.hook(action, 'scaleY', 0);
        
        checkViewportWidth();

        for (var i = 0, l = navItem.length; i < l; i++) {
            Velocity.hook(navItem[i], 'translateX', '-50%');
        }

        toggle.addEventListener('click', onToggleClick);
        win.addEventListener('resize', checkViewportWidth);
    }
    
    var checkViewportWidth = debounce(function() {
        if (win.innerHeight > win.innerWidth) {
            size = '100vh';
        } else {
            size = '100vw';
        }
        action.style.height = size;
        action.style.width = size;        
    }, 100);

    function onToggleClick() {
        if (!toggle.classList.contains('velocity-animating')) {
            if (!toggle.classList.contains('active')) {
                toggle.classList.add('active');
                Velocity(toggle, {
                    rotateZ: [-45, 0]
                }, durationOut, easeOut);
                Velocity(action, {
                    scaleX: 2.5,
                    scaleY: 2.5
                }, durationOut, easeOut);
                Velocity(navItem[0], {
                    translateY: -359
                }, durationOut, easeOut);
                Velocity(navItem[1], {
                    translateY: -247
                }, durationOut, easeOut);
                Velocity(navItem[2], {
                    translateY: -135
                }, durationOut, easeOut);
            } else {
                toggle.classList.remove('active');
                Velocity(toggle, {
                    rotateZ: 0
                }, durationIn, easeIn);
                Velocity(action, {
                    scaleX: 0,
                    scaleY: 0
                }, durationIn, easeIn);

                for (var i = 0, l = navItem.length; i < l; i++) {
                    Velocity(navItem[i], {
                        translateY: 0
                    }, durationIn, easeIn);
                }
            }
        }
        
        if (!header.classList.contains('hidden')) {
            header.classList.add('hidden');
            Velocity(header, {opacity: 0}, durationOut, easeOut);
        }

    }
    
    function debounce(func, wait, immediate) {
        var timeout;
        return function() {
            var context = this, args = arguments;
            var later = function() {
                timeout = null;
                if (!immediate) func.apply(context, args);
            };
            var callNow = immediate && !timeout;
            clearTimeout(timeout);
            timeout = setTimeout(later, wait);
            if (callNow) func.apply(context, args);
        };
    }    

    doc.addEventListener('DOMContentLoaded', init);
})();
            
          
!
999px
🕑 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.

Console