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

              
                <div class="wrapper">
  <div class="block one"></div>
  <div class="block two"></div>
</div>

<div class="triangle-button" data-open=""></div>
              
            
!

CSS

              
                .wrapper {
  position: relative;
  width: 100%;
  min-height: 100vh;
}

.block {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  
  &.one {
    left: 0;
    background-color: seagreen;
    clip-path: polygon(0 0, 20% 0, 80% 100%, 0 100%);
    z-index: 1;
  }
  &.two {
    right: 0;
    background-color: coral;
  }
}

.triangle-button {
	position: fixed;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 100px 0 0 100px;
	border-color: transparent transparent transparent seagreen;
	z-index: 20;

	&::before {
		content: "";
		position: absolute;
		display: block;
		border-style: solid;
		border-width: 20px 0 0 20px;
		border-color: transparent transparent transparent #272727;
		transform: translate(-80px, -40px);
		opacity: .6;
	}

	&[data-open="two"] {
		right: 0;
		top: 0;
		border-width: 0 100px 100px 0;
		border-color: transparent coral transparent transparent;

		&::before {
			border-width: 0 20px 20px 0;
			border-color: transparent #272727 transparent transparent;
			transform: translate(60px, 20px);
		}
	}

	&[data-open="one"] {
		left: 0;
		bottom: 0;
	}
}

              
            
!

JS

              
                    const openedLeft = {
      leftSide: {
        duration: 1.4,
        clipPath: "polygon(-100% 0, 100% 0, 175% 150%, -30% 100%)"
      },
      rightSide: {
        duration: 1.2,
        xPercent: 50
      }
    };
    const openedRight = {
      leftSide: {
        duration: 1.4,
        xPercent: -100
      },
      rightSide: {}
    };
    let leftSide = document.querySelector(".block.one");
    let rightSide = document.querySelector(".block.two");
    let triangleButton = document.querySelector(".triangle-button");

    // open / close animation timelines
    const timeLineLeft = gsap.timeline(); // left
    const timeLineRight = gsap.timeline(); // right


    function animateSide(side, timeline) {
      timeline
        .to(".block.one", side.leftSide, "expand")
        .to(".block.two", side.rightSide, "expand");
    }

    function hoverSide(side, timeline, progress) {
      timeline
        .to(".block.one", side.leftSide, "expand")
        .to(".block.two", side.rightSide, "expand").tweenTo(progress);
    }

    function openSide(elem) {
      let side = elem.classList.contains("one") ? openedLeft : openedRight;
      let whichTl = side === openedLeft ? timeLineLeft : timeLineRight;

      $(".triangle-button").fadeIn("slow");
      if (side === openedLeft) {
        triangleButton.dataset.open = "two";
      } else {
        triangleButton.dataset.open = "one";
      }

      animateSide(side, whichTl);

      whichTl.play().invalidate();
      $("body").css("overflow-y", "auto");
    }

    leftSide.addEventListener("click", (e) => {
      e.stopPropagation();
      e.currentTarget.classList.add("opened");
      e.currentTarget.classList.remove("animate-hover");
      openSide(e.currentTarget);
    });

    rightSide.addEventListener("click", (e) => {
      e.stopPropagation();
      e.currentTarget.classList.add("opened");
      e.currentTarget.classList.remove("animate-hover");
      openSide(e.currentTarget);
    });

    leftSide.addEventListener("mouseenter", (e) => {
      e.stopPropagation();
      hoverSide(openedLeft, timeLineLeft, .01);
    });

    leftSide.addEventListener("mouseleave", (e) => {
      e.stopPropagation();
      timeLineLeft.reverse();
    });

    // open side at any point of document

    triangleButton.addEventListener("click", (e) => {
      e.stopPropagation();
      if (e.currentTarget.dataset.open === "right") {
        openSide(leftSide);
      }
      if (e.currentTarget.dataset.open === "left") {
        openSide(rightSide);
      }
    });
              
            
!
999px

Console