<button class="btn--pitfall" data-splitting>Unsubscribe</button>
@import url("https://fonts.googleapis.com/css?family=Lato:700&display=swap");

body,
html {
  height: 100%;
}

body {
  display: grid;
  place-items: center;
  font-family: "Lato", sans-serif;
  color: white;
  background: dodgerblue;
}

.btn--pitfall {
  --perspective: 200px;
  --rotation: 65deg;
  --duration: 200ms;
  --ease: cubic-bezier(0.33, 1, 0.68, 1);

  all: unset;
  cursor: pointer;
  position: relative;
  padding: 1rem 2rem;
  font-family: inherit;
  font-size: 1.25rem;
  border: 2px dashed transparent;
  transition: border-color 0s;

  &::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    transform-origin: 50% 100%;
    border-radius: 0.125rem;
    transform: perspective(var(--perspective));
    transition: var(--duration) var(--ease);
    pointer-events: none;
    z-index: 1;
  }

  &::before {
    background-color: black;
    transition-property: transform;
  }

  .word {
    position: relative;
    pointer-events: none;
    z-index: 2;
  }
}

.btn--pitfall:hover {
  border-color: rgba(white, 0.2);
  transition-duration: var(--duration);
  transition-delay: calc(var(--duration) * 3.5);
  animation: cursor-swap calc(var(--duration) * 4) linear forwards,
    zoom var(--duration) linear forwards;

  &::before {
    transform: perspective(var(--perspective));
    animation: pit calc(var(--duration) * 4) var(--ease) forwards;
  }

  .char {
    animation: fall calc(var(--duration) * 2) linear forwards;
    animation-delay: calc(var(--distance-sine) * 0.04s);
  }
}

@keyframes zoom {
  60% {
    transform: scale(1.2);
  }
}

@keyframes cursor-swap {
  0%,
  80% {
    cursor: grab;
  }
  100% {
    cursor: help;
  }
}

@keyframes fall {
  20% {
    transform: scale(calc(1 * var(--distance-percent) + 1.5))
      rotate(calc(15deg * var(--distance-sine))) translateY(-20%);
  }
  40% {
    transform: scale(calc(1 * var(--distance-percent) + 1.2))
      rotate(calc(25deg * var(--distance-sine))) translateY(-30%);
  }
  60% {
    transform: scale(calc(1 * var(--distance-percent) + 1.5))
      rotate(calc(15deg * var(--distance-sine))) translateY(-35%);
  }
  80% {
    opacity: 1;
    transform: scaleY(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scaleY(1.5) translateY(150%);
  }
}

@keyframes pit {
  40%,
  60% {
    transform: perspective(var(--perspective)) rotateX(var(--rotation))
      translateY(100%);
  }
  80% {
    transform: perspective(var(--perspective)) rotateX(var(--rotation))
      translateY(100%) scaleX(1.2);
  }
  95% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: perspective(var(--perspective)) rotateX(var(--rotation))
      translateY(100%) scaleX(0.001);
  }
}
View Compiled
Splitting();

External CSS

  1. https://unpkg.com/splitting@1.0.0/dist/splitting.css

External JavaScript

  1. https://unpkg.com/splitting/dist/splitting.min.js