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

              
                <div class="modal">
</div>
<div class="play-button" onclick="playAnimation()">
  <svg class="lemon-play" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 37.2 62.4" style="enable-background:new 0 0 37.2 62.4;" xml:space="preserve">
  <style type="text/css">
    .yellow1{fill:#F6D82F;}
    .blue{fill:#46C1C0;}
    .orange{fill:#F4B128;}
    .red{fill:#F16646;}
    .yellow{fill:#F5D72D;}
  </style>
  <g id="lemon">
    <path class="yellow1" d="M35.8,25.5c0.5-0.4,1.1-0.8,1.3-1.4c0.2-0.5-0.2-2-0.9-2c0.1,0.1,0.2,0.2,0.4,0.3c-1.5-1.4-1-4.7-1.4-6.5
      c-1-4.3-3.2-8.2-6.6-11c-4.5-3.8-11.1-6.1-16.9-4.2c5.2-1.3,9.9,1.9,11.8,6.7c2.3,5.9,1.2,12.7-1.8,18c-2.4,4.2-6.4,8.6-11.5,8.9
      C5,34.6,1.7,30,0,25.7c1.3,7.1,8.3,10.6,14.9,11c4.6,0.3,9.4-0.9,13.2-3.5C31.2,31.2,32.8,27.8,35.8,25.5
      C35.8,25.5,35.8,25.6,35.8,25.5z"/>
    <path class="blue" d="M19.4,25c-3-2.2-6-4.5-9-6.7c0.3,4.3,0.6,8.6,0.9,12.8c0,0.3-0.1,1.1,0.1,1.4c0.5,0.9,2.5-0.4,3.1-0.7
      c1.9-1.1,3.4-2.7,4.6-4.6C19.4,26.6,20,25.6,19.4,25z"/>
    <path class="orange" d="M21.3,22.9c0.9-1.8,1.5-3.6,1.8-5.5c0.1-1.1,0.6-3.7-0.5-4.6c-0.4-0.3-2.4,0.9-2.9,1.1
      c-1.2,0.6-2.5,1.1-3.7,1.7c-1.6,0.7-3.2,1.5-4.8,2.1c1.7,1.2,3.4,2.5,5.1,3.7c1,0.7,2,1.4,3,2.2C20.2,24.2,20.7,24.2,21.3,22.9z"/>
    <path class="yellow1" d="M17.7,3.1c-0.2,0.8-0.6,1.5-1,2.2c-0.8,1.5-1.6,2.9-2.3,4.4c-1.2,2.3-2.4,4.6-3.7,6.9c0.2,0,0.7-0.3,0.9-0.4
      c0.9-0.4,1.8-0.8,2.7-1.2c2.5-1.1,4.9-2.2,7.4-3.3C24.9,10.3,19.8,1.5,17.7,3.1C17.7,3.3,17.8,3,17.7,3.1z"/>
    <path class="yellow1" d="M6.5,6.3c1,1.2,1.3,3.3,1.8,4.7c0.6,1.7,1.2,3.4,1.8,5.1C12,12.4,13.8,8.7,15.7,5c0.3-0.5,0.5-1,0.8-1.5
      c0.8-1.5-0.4-1.8-1.6-1.7c-1.4,0-2.8,0.4-4,1C9.9,3,5.7,5.1,6.5,6.3z"/>
    <path class="yellow1" d="M2.6,15.3c2.2,0.3,4.4,0.6,6.5,0.9C8.1,13.4,7,10.6,6,7.9c-0.7-2-2.1,0.7-2.7,1.7c-0.6,1.2-1.2,2.4-1.7,3.7
      c-0.2,0.5-0.3,1.1-0.3,1.6C1.6,15.4,2.1,15.2,2.6,15.3C3.8,15.4,2.3,15.2,2.6,15.3z"/>
    <path class="yellow1" d="M0.8,24.6C0.9,25,1,25.4,1.3,25.7c2.3-3,5.1-5.7,7.6-8.6c-1.3-0.2-2.7-0.3-4-0.5c-0.8-0.1-3.3-0.8-3.9-0.1
      c-0.5,0.6-0.3,2.7-0.3,3.5C0.5,21.6,0.6,23.1,0.8,24.6C0.9,25.2,0.6,23.2,0.8,24.6z"/>
    <path class="red" d="M9,33.2c1.4,0,1.2-1.1,1.2-2.1c-0.1-1.6-0.2-3.2-0.3-4.7c-0.2-2.7-0.3-5.4-0.5-8.1c-0.9,0.7-1.8,1.9-2.5,2.8
      C5.6,22.5,4.3,24,3,25.5c-0.3,0.3-0.5,0.6-0.8,0.9c-0.7,0.9,0.7,2.9,1.2,3.6C4.6,31.4,7,33.2,9,33.2z"/>
  </g>
  <g id="drop">
    <path class="yellow" d="M4.6,48c-2.8,4.4-3.2,7-0.1,11.2c3.1,4.2,8.2,4.3,11.3,0.2c3.2-4.1,2.8-6.7,0.1-11.2
      c-1.7-2.7-5.6-11.5-5.6-11.5S6.3,45.4,4.6,48z"/>
  </g>
  </svg>
  <p>Play</p>
</div>

              
            
!

CSS

              
                @mixin transform-origin($x, $y) {
	-webkit-transform-origin: $x $y;
	-ms-transform-origin: $x $y;
	transform-origin: $x $y;
}

@mixin rounded($radius: 4px) {
	-webkit-border-radius: $radius;
	-moz-border-radius: $radius;
	border-radius: $radius;
	background-clip: padding-box;
}

@mixin transform-scale($factor-width, $factor-height) {
	-webkit-transform: scale($factor-width, $factor-height);
	-moz-transform: scale($factor-width, $factor-height);
	-ms-transform: scale($factor-width, $factor-height);
	-o-transform: scale($factor-width, $factor-height);
	transform: scale($factor-width, $factor-height);
}

@mixin transition($transition) {
	-webkit-transition: $transition;
	-moz-transition: $transition;
	-ms-transition: $transition;
	-o-transition: $transition;
	transition: $transition;
}

.modal {
  width: 100%;
  height: 100%;
}

path {
        @include transition(all .5s);
        opacity: 1;
        @include transform-scale(1, 1);
        @include transform-origin(50%, 50%);
        &.hide-polygon {
            opacity: 0;
            @include transform-scale(1, 0);
        }
    }

.play-button {
  @include rounded(10px);
  position: absolute;
  z-index: 50;
  top: 1%;
  right:1%;
  width: 100px;
  height: 75px;
  padding: 10px;
  background: #ffffff;
  text-align: center;
  p {
    margin-top: -20%;
  }
}

.lemon-play {
  width: 40%;
}

              
            
!

JS

              
                //creates an jquery-esk addcClass funtion
function addClass(el, className) {
  if (el.classList)
    el.classList.add(className)
  else if (!hasClass(el, className)) el.className += " " + className
}

//gets modal window
var modal = document.querySelector('.modal');

//Create trianglify pattern
var pattern = Trianglify({
  width: window.innerWidth,
  height: window.innerHeight,
  variance:.9,
  x_colors: [
    '#FDE600',
    '#FBED23',
    '#FCD806',
    '#FCED19',
    '#FCDA03',
    '#FAEC24',
    '#F8EC29',
    '#F8EC25',
    '#FDDF00',
    '#FFE200',
    '#FDDB00',
    '#F8EC27',
    '#FDE500'
  ],
  y_colors: [
    '#FDE600',
    '#FBED23',
    '#FCD806',
    '#FCED19',
    '#FCDA03',
    '#FAEC24',
    '#F8EC29',
    '#F8EC25',
    '#FDDF00',
    '#FFE200',
    '#FDDB00',
    '#F8EC27',
    '#FDE500'
  ]
});

//appends pattern to modal window
modal.appendChild(pattern.svg());

//gathers the polygons created by Trianglify
var polygons = document.querySelectorAll('.modal path');  

// Polygon animation 
function animatePolygons() {
  // Starts polygon animation
  setTimeout(function() {
    hidePolygon(polygons.length);
  }, 1000);
}

//Adds the css animation to the individual polygons
function hidePolygon(count) {
  $(polygons[count]).attr('class', 'hide-polygon');

  count--;

  if(count > 0) {
    setTimeout(function() {
      hidePolygon(count);
    }, 5);
  } else {
    modal.querySelector('svg').style.display = 'none';
  }
}

//PLAY BUTTON
// Gets drop in svg play button
var drop = document.getElementById("drop");

// Sets drop 
TweenMax.set(drop, {scale: 0, transformOrigin: '50% 0%'});

//function called to start animation
function playAnimation() {
    // Gets play button
    var button = document.querySelector(".play-button");
    // Gets lemon
    var lemon = document.getElementById("lemon");
  
    // Creates gsap timeline for lemon squeeze 
    var tl = new TimelineMax();
    tl.to(lemon, .3, {transformOrigin: "50% 50%", scaleX: .6})
    .to(lemon, .3, {scaleX: 1}, '+=1');
  
    //Creates gsap timeline for drop
    var tl = new TimelineMax();
    tl.to(drop, 1, {scale:1})
    .to(drop, .7, {y: 50})
    .to(button, .7, {opacity: 0});
  
    animatePolygons(); 
}
              
            
!
999px

Console