cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <button class="button">Open</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>
            
          
!
            
              @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;
  &:focus {
    outline: none;
    opacity: 0;
  }
  &:focus ~ .modal {
    clip-path: polygon(0 0, 100% 0%, 100% 100%, 0% 100%); // full rectangle
  }
  &:focus ~ .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
  }
}
            
          
!
            
              // To do:
// Started to lag after adding content inside.

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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console