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="container">
  <section class="spacer intro">
    <svg xmlns="http://www.w3.org/2000/svg" id="General" x="0" y="0" version="1.1" viewBox="0 0 86 30" aria-hidden="true" focusable="false">
      <path fill="currentColor" d="M14.4 17c-.5-1.1.1-2.1.7-3.2.5-.9 1-2.3 2-1.3 0 .5-.1.7-.3 1 .7.8.3 2.7-.2 3.4 0 1.5.2 2.8.4 4.1 1.5-1 2.8-2.6 3.8-4.3.7-1.1 1.3-2.4 3.2-2.4.4.4.4 1.2.7 1.7 1-.1 2.1-2.8 3.2-2.5.6.2.4 1.1.6 2 .5-.1.8-1 1.5-.9 1.1.1 1.2 2.4 1.6 3.5 3-1.7 4.6-5.4 6.6-8.4-.7-.7-5.3.4-5.5-.8-.1-1 1.2-.7 1.7-.7 1.4 0 2.9.1 4.1.2C39.6 5.7 40.2 2.3 44 2c.9 1.3 0 2.9-.7 3.8-.7 1.1-1.6 2-2.3 2.8 2.4 0 4.4 0 6.6-.5.6-.1 2.7-1.1 2.7.1 0 .7-1.7.9-2.8 1.1-1.7.3-4.3.6-6.5.5-1-.1-1.5 0-2 .7-.1 1.7-1.5 3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 10.3 1.6-1.6 4-8.1 1.6-10.3zm3.3 5.4c-.7 1.7-1.4 3.4-1.2 5 1-.8 2.3-1.9 3.3-3.3 1.2-1.5 2.9-4.2 1.4-5.9-2.1.2-2.8 2.6-3.5 4.2zm-3.8 5.7c.3.2.8.1 1.2 0 0-.4-.1-1 0-1.5s.5-1.7.3-1.5c-.5 1-.9 2.1-1.5 3zm-22.8 0c.1-.3.3-.5.5-.8-.3 0-.7.5-.5.8zm20.6.8c.1-.3.5-.3.5-.7-.3-.2-.4-.6-.7-.9 0 .6-.1 1.3.2 1.6zm-25 3.5c.1.1.6.1.7 0 0-.1 0-.2.1-.3-.2-.3-.8 0-.8.3zm16.4 8.5c1.3-1.7 1.3-5.3.9-8-2.6 1-3.9 6.5-.9 8z"></path>
    </svg>
  </section>

  <div class="wrapper">

    <div class="rolo">
      <!--  using js to populate for refresh purposes  -->
    </div>
    <div class="spin-me">Drag Me</div>
  </div>
  <section class="spacer"></section>

</div>

<!-- modal view -->
<div class="modal">
  <div data-flip-id="img" class="modal-image"><img src="" /></div>
</div>
              
            
!

CSS

              
                @font-face {
  font-family: "Untitled";
  src: url(https://assets.codepen.io/1600187/untitled-sans-regular.woff2)
    format("woff2");
  font-weight: 400;
}

body {
  line-height: 2;
  font-family: Untitled, sans-serif;
  text-transform: uppercase;
  color: #333;
  font-size: 14px;
}

.spacer {
  height: 20vh;
  z-index: 0;
  text-align: center;
}

.intro {
  display: grid;
  place-content: center;

  @keyframes bounce {
    from {
      transform: translateY(-10%);
    }

    to {
      transform: translateY(10%);
    }
  }

  svg {
    width: 86px;
  }

  span {
    display: inline-block;
    animation: bounce 1s alternate infinite ease-in-out;
  }
}

.container {
  overflow: hidden;
  width: 100%;
  // background: black;
}
.wrapper {
  z-index: 1;
  perspective: 1800px;
  perspective-origin: center -300px;
  transform-style: preserve-3d;
  position: relative;
  min-height: 100vh;
  width: 100%;
  pointer-events: none;
  display: grid;
  place-content: center;
}

.spin-me {
  position: absolute;
  bottom: calc(20vh + 15px);
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  z-index: 0;
}

.rolo {
  position: absolute;
  height: 100vh;
  width: 100%;
  top: 10%;
  left: 50%;
  transform-style: preserve-3d;
  transform-origin: center left;
}

.item {
  position: absolute;
  top: 0;
  left: 0;
  aspect-ratio: 3 / 2;
  width: 450px;
  z-index: 1;
  pointer-events: all;
  background: #777;
  transform-style: preserve-3d;

  &.active-item {
    z-index: 2;
  }

  .active & {
    pointer-events: none;
  }

  .card-text {
    z-index: 1;
    position: absolute;
    bottom: 20px;
    right: 20px;
    padding: 20px;
    background: #fff;
    backface-visibility: hidden;
    transform: translateZ(0px);

    &--back {
      transform: translateZ(-1px) rotatey(180deg);
      background: #fff;
    }
  }

  img {
    height: 100%;
    width: 100%;
    position: absolute;
    object-fit: cover;
    object-position: top center;
    z-index: 0;
    // backface-visibility: hidden;
  }
}

// modal styles
.modal {
  cursor: zoom-out;
  position: fixed;
  opacity: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0) grayscale(0);
  pointer-events: none;
  z-index: 3;

  &.active {
    display: flex;
    opacity: 1;
    pointer-events: all;
    background-color: rgba(0, 0, 0, 0.69);
    backdrop-filter: blur(5px) grayscale(100%);
    transition: background-color 0.2s ease-in, backdrop-filter 0.2s ease;
  }

  .modal-image {
    aspect-ratio: 16 / 9;
    width: 90%;
    max-width: 1260px;
    background: #eee;
    margin: 40px auto;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.55);

    img {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: top center;
    }
  }
}

              
            
!

JS

              
                gsap.registerPlugin(Draggable, InertiaPlugin);
gsap.config({ trialWarn: false });

// populating images
const rolo = document.querySelector(".rolo");
for (let i = 0; i < 10; i++) {
  rolo.innerHTML += `<div class="item a" data-url="https://source.unsplash.com/random/800x800/?${i}"><div class="card-text card-text--back">This is the Resource Title ${i}</div><img src="https://source.unsplash.com/random/800x800/?${i}" /><div class="card-text">This is the Resource Title ${i}</div></div>`;
}

// setup tween for draggable... will likely be a scroll/observer experience in the future
const items = gsap.utils.toArray(".item");
const xOffset = 30;

items.forEach((item, i) => {
  gsap.set(item, {
    transformOrigin: "-30px 0",
    x: xOffset,
    rotateY: (i * 360) / items.length
  });
});

const updateZIndex = () => {
  items.forEach((item) => {
    const backText = item.querySelector(".card-text--back");
    gsap.utils.wrap(0, 360, gsap.getProperty(item, "rotateY")) < 270
      ? gsap.set(backText, { zIndex: 2 })
      : gsap.set(backText, { zIndex: 0 });
  });
};

const roloTL = gsap.to(items, {
  rotateY: "+=360",
  duration: 5,
  ease: "none",
  paused: true,
  onUpdate: updateZIndex
});
updateZIndex();
// draggable consts
const proxy = document.createElement("div");
const itemCount = items.length;
const itemW = items[0].offsetWidth;
const wrapW = itemCount * itemW;

// flip consts
let activeItem;
const modal = document.querySelector(".modal");
const modalImage = modal.querySelector(".modal-image");
let normalizeTL;

// circumference of circle
const c = (itemW + xOffset) * 2 * Math.PI;
// arc distance from edge to edge (for snapping)
const seg = c / itemCount;

// wrap for tween progress scrub
const wrapVal = gsap.utils.wrap(0, c);

const drag = Draggable.create(proxy, {
  type: "x",
  trigger: ".item",
  inertia: true,
  onDrag: updateProgress,
  onThrowUpdate: updateProgress,
  snap: {
    x: (x) => {
      return Math.round(x / seg) * seg;
    }
  }
});

function updateProgress() {
  roloTL.progress(wrapVal(this.x) / c);
}
const ctx = gsap.context(() => {});

// FLIP into modal
items.forEach((item) => {
  item.addEventListener("click", () => {
    drag[0].disable();
    drag[0].tween && drag[0].tween.kill();
    activeItem = item;
    item.classList.add("active-thumb");
    item.parentElement.classList.add("active");
    item.dataset.flipId = "img";

    normalizeTL = gsap
      .timeline({
        onComplete: () => {
          gsap.set(item, { opacity: 0 });
          const state = Flip.getState([item, modalImage]);
          modalImage.querySelector("img").setAttribute("src", item.dataset.url);
          modal.classList.add("active");
          modalImage.style.display = "block";

          Flip.from(state, {
            duration: 0.4,
            simple: true,
            ease: "sine.inOut"
          });
        },
        onReverseComplete: () => {
          item.parentElement.classList.remove("active");
          drag[0].enable();
        }
      })
      .to(item, {
        yPercent: -120,
        duration: 0.2
      })
      .to(
        item,
        {
          x: 0,
          xPercent: -50,
          rotateY: "0_short",
          duration: 0.2
        },
        0.1
      );
  });
});

// FLIP out of modal
modal.addEventListener("click", () => {
  activeItem.dataset.flipId = "img";
  gsap.set(activeItem, { opacity: 1 });

  // need to find a way to disable the rotateY
  const state = Flip.getState([modalImage, activeItem]);

  modal.classList.remove("active");

  Flip.from(state, {
    duration: 0.4,
    simple: true,
    ease: "sine.inOut",
    onComplete: () => {
      modalImage.querySelector("img").setAttribute("src", "");
      activeItem.classList.remove("active-thumb");
      activeItem.dataset.flipId = "img";
      normalizeTL.reverse();
    }
  });
});

              
            
!
999px

Console