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="test">
  <div class="a">
    <div class="parent">
      <h1 data-flip-id="title1">Positively Amazing Title One</h1>
    </div>
    <div class="parent">
      <h1 data-flip-id="title2">Undoubtedly Astonishing Title Two</h1>
    </div>
    <div class="parent">
      <h1 data-flip-id="title3">Incapacitatingly Astounding Title Three</h1>
    </div>
  </div>
  <div class="b">
    <div class="article-wrapper">
      <div class="title-container"></div>
      <div class="article-container"></div>
    </div>
  </div>
</div>
<div class="btn-wrapper">

</div>

<div class="article-overlay">
  <div class="article-relative">
    <div class="article-text uno">
      <p class="split-para">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec commodo ex vitae eleifend vestibulum. Nulla pretium mollis gravida. Nulla non nisi nisl. Pellentesque fermentum eros nec nulla posuere, sed hendrerit lectus pharetra. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec hendrerit ligula, sed elementum dui. </p>
      <p class="split-para">Phasellus ut magna condimentum, faucibus felis vitae, viverra mi. Aenean dictum auctor finibus. Sed sollicitudin in nulla et vestibulum. Vestibulum sagittis mauris eu nisi luctus eleifend. Mauris sapien massa, venenatis eu sapien vel, dignissim rutrum justo. Donec eu nibh tincidunt, venenatis velit quis, vestibulum arcu. Phasellus sit amet erat posuere libero dictum sodales. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras dignissim molestie tellus, viverra consequat orci tempus quis.</p>
    </div>

    <div class="article-text dos">
      <p class="split-para">DOS Pellentesque fermentum eros nec nulla posuere, sed hendrerit lectus pharetra. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec hendrerit ligula, sed elementum dui. </p>
      <p class="split-para">Mauris sapien massa, venenatis eu sapien vel, dignissim rutrum justo. Donec eu nibh tincidunt, venenatis velit quis, vestibulum arcu. Phasellus sit amet erat posuere libero dictum sodales. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras dignissim molestie tellus, viverra consequat orci tempus quis.</p>
    </div>

    <div class="article-text tres">
      <p class="split-para">TRES Pellentesque fermentum eros nec nulla posuere, sed hendrerit lectus pharetra. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec hendrerit ligula, sed elementum dui. </p>
      <p class="split-para">Mauris sapien massa, venenatis eu sapien vel, dignissim rutrum justo. Donec eu nibh tincidunt, venenatis velit quis, vestibulum arcu. Phasellus sit amet erat posuere libero dictum sodales. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras dignissim molestie tellus, viverra consequat orci tempus quis.</p>
    </div>
  </div>

</div>

<button class="ss_unbutton ss_preview__back" id="bc_copy-btn"><svg width="100px" height="18px" viewBox="0 0 50 9">
    <path vector-effect="non-scaling-stroke" d="m0 4.5 5-3m-5 3 5 3m45-3h-77"></path>
  </svg></button>
              
            
!

CSS

              
                @font-face {
  font-family: "Aeonik";
  src: url("https://assets.website-files.com/638e3cc6a18ee8722ccbd9a5/638e3e2428219509205ae974_Aeonik.otf")
    format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Aeonik";
}

.test {
  width: 100%;
  padding: 1rem;
  display: flex;
  color: #1a1a1a;
  position: relative;
}

.a {
  width: 80%;
  /*   background-color: blue; */
  position: absolute;
  z-index: 10;
}

.a .parent {
  height: 40px;
}

.a h1 {
  font-size: 1.5rem;
  cursor: pointer;
  color: #1a1a1a;
  transition: color 0.3s ease-out;
}

.a h1:hover {
  color: #00ffa3;
  transition: 0.2s ease-in-out;
}

.b {
  width: 100%;
  /*   background-color: green; */
  position: absolute;
  height: 10vh;
  z-index: 5;
}

.b .title-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.b .title-container h1 {
  font-size: 2.5rem;
}

.btn-wrapper {
  width: 100%;
  padding: 2rem;
  display: flex;
  justify-content: center;
}

button {
  padding: 0.5rem 2rem;
  cursor: pointer;
  font-size: 20px;
}

.article-overlay {
  position: fixed;
  height: 100%;
  width: 100%;
  top: 0;
  right: 0;
  /*   background: coral; */
  margin-top: 20vh;
}

.article-relative {
  position: relative;
  margin: auto;
  width: 50%;
  height: 100%;
}

.article-text {
  position: absolute;
  font-family: "Aeonik";
  /*   background: coral; */
  opacity: 0;
}

.uno,
.dos,
.tres {
}

.open {
  height: 100%;
  overflow-y: scroll;
}

.lineParent {
  overflow: hidden;
}

.ss_preview__back {
  position: fixed;
  top: 60vh;
  margin: auto;
  width: 100%;
  stroke: #1a1a1a;
  cursor: pointer;
  fill: none;
  /*   grid-area: 3 / 1 / 4 / 2; */
  justify-self: center;
  align-self: end;
  transition: 0.25s ease-in-out;
}

.ss_preview__back:hover {
  stroke: #00ffa3;
  transition: 0.25s ease-in-out;
}

.ss_unbutton {
  background: none;
  border: 0;
  padding-top: 5vh;
  margin: 0;
  font: inherit;
  opacity: 0;
}

.ss_unbutton:focus {
  outline: none;
}

              
            
!

JS

              
                console.clear();

gsap.registerPlugin(Flip, SplitText);

const btn = document.getElementById("bc_copy-btn");
const parents = gsap.utils.toArray(".parent");
const largeParent = document.querySelector(".title-container");
const titles = gsap.utils.toArray("h1");
const articleTexts = gsap.utils.toArray(".article-text");
let target;
let currentIndex = null;

const splitArticles = articleTexts.map((articleText) => {
  const paragraphs = gsap.utils.toArray(".split-para", articleText)
  const split = new SplitText(paragraphs, { type: "lines" });
  gsap.set(split.lines, { opacity: 0, y: 40, });
  return split
});

console.log(splitArticles);

// Create a timeline
let tl = gsap.timeline();

titles.forEach((e, i) => {
  e.addEventListener("click", () => {
    if (target) return;
    const state = Flip.getState(e, { props: "fontSize" });
    target = e;
    currentIndex = i;
    largeParent.appendChild(e);
    Flip.from(state, {
      duration: 1,
      ease: "power3.out",
      absolute: true
    });
    
    gsap.set(articleTexts[i], { opacity: 1 });

    // Fade out inactive titles
    tl.to(
      titles.filter((title) => title !== e),
      { opacity: 0, duration: 1, ease: "power3.out" }
    );

    // Fade in button
    tl.to(
      ".ss_unbutton",
      { opacity: 1, duration: 1, ease: "power3.out" },
      "-=0.75"
    );

    tl.to(splitArticles[i].lines, { y: 0, ease: "cubic", duration: 0.8, stagger: 0.1, opacity: 1, },"<");
  });
});

btn.addEventListener("click", () => {
  const previousIndex = currentIndex;
  // Fade out current article text if it exists
  if (previousIndex !== null) {
    tl.to(splitArticles[previousIndex].lines, {
      opacity: 0,
      y: 40,
      duration: 1,
      stagger: 0.1,
      ease: "power3.out"
    });
  }

  tl.add(thenFlip, "<+=0.3");

  // Fade out button
  tl.to(".ss_unbutton", { opacity: 0, duration: 0.75, ease: "cubic" }, "<");

  function thenFlip() {
    if (!target) return;
    const state = Flip.getState(target, { props: "fontSize" });
    parents[currentIndex].appendChild(target);
    target = null;
    currentIndex = null;
    Flip.from(state, {
      duration: 1,
      ease: "power3.out",
      absolute: true
    });
  }

  // Fade in inactive titles
  tl.to(titles, { opacity: 1, duration: 1, ease: "power3.out" });
});

              
            
!
999px

Console