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

Auto Save

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

              
                <button class="button">Hold</button>
<div class="modal">
  <div class="modal__content">
    <p>This is a test to replicate Androids native app-opening animation. Click on the edges to close this modal.</p>
    <p>The animation here is made with a clip-path polygon that transition from the button to fullscreen. The default state of the clip-path creates the buttons background.</p>    
  </div>
    
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Roboto:500);
html, body {
  background: #f7b9ca;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

$bw : 3em; // Button width
$bh : 1.5em;  // Button height

.modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #22cc99;//844a2f
  width: 100%;
  height: 100%;
  clip-path: polygon( 
    calc(50% - #{$bw} ) calc(50% - #{$bh} ), 
    calc(50% + #{$bw} ) calc(50% - #{$bh} ), 
    calc(50% + #{$bw} ) calc(50% + #{$bh} ), 
    calc(50% - #{$bw} ) calc( 50% + #{$bh} ) ); // center invisible
  transition: clip-path 0.4s cubic-bezier(0,.58,.36,1);
  display: flex;
  justify-content: center;
  align-items: center;
}


.modal__content {
  opacity: 0;
  transform: translate3D(0,-1em,0);
  transition: opacity 0.1s 0s, transform 0.3s 0s; //close
  padding: 2em;
  max-width: 30em;
  color: #fff;
}

button {
  background: transparent;
  border: none;
  padding: 1em;
  color: #fff;
  z-index: 1;
  transition: opacity 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  &:active {
    outline: none;
    opacity: 0;
  }
  &:active ~ .modal {
    clip-path: polygon(0 0, 100% 0%, 100% 100%, 0% 100%); // full rectangle
  }
  &:active ~ .modal .modal__content {
    opacity: 1;
    transform: translate3D(0,1em,0);
    transition: opacity 0.3s 0.2s, transform 0.6s 0.2s cubic-bezier(0,.65,.06,.98); //open
  }
}
              
            
!

JS

              
                var button = document.querySelector('.button');
var modal = document.querySelector('.modal');

// Set will-change when the element is hovered
button.addEventListener("focus", hintBrowser, true);
button.addEventListener("blur", hintBrowser, true);

button.addEventListener('click', hintBrowser );
modal.addEventListener("transitionend", removeHint, false);

function hintBrowser() {
  // The optimizable properties that are going to change
  // in the animation's keyframes block
  modal.style.willChange = 'clip-path';
  console.log('add will-change');
}

function removeHint() {
  this.style.willChange = 'auto';
  console.log('remove will-change');
}
              
            
!
999px

Console