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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <a href="https://youtu.be/6hxYjCCNcwA" target="_blank" data-keyframers-credit style="color: #000"></a>
<script src="https://codepen.io/shshaw/pen/QmZYMG.js"></script>

<main id="app" data-state="detail">
  <section class="screen" data-scene="gallery">
    <figure style="--i: 0">
      <div class="img-wrap" data-key="img1">
        <img src="https://source.unsplash.com/vpaHZEYx35U/800x900">
      </div>
      <figcaption class="bordered-title">
        Magna Saxa ⛰🎷
      </figcaption>
    </figure>
    
    <figure style="--i: 1">

      <div class="img-wrap">
        <img src="https://source.unsplash.com/P8emRhbM0RU/800x900">
      </div>
      <figcaption class="bordered-title">
        Hello, lake inside rocks!
      </figcaption>

    </figure>
    
    <figure style="--i: 2">

      <div class="img-wrap">
        <img src="https://source.unsplash.com/P_vuELoVt3M/800x900">
      </div>
      <figcaption class="bordered-title">
        Hello, lake next to rocks!
      </figcaption>

    </figure>
    <figure style="--i: 3">

      <div class="img-wrap">
        <img src="https://source.unsplash.com/vpaHZEYx35U/800x900">
      </div>

      <figcaption class="bordered-title">
        Hello, rocks again!
      </figcaption>
    </figure>
  </section>

  <section class="screen" data-scene="detail">
    <figure>
      <div class="img-wrap" data-key="img1">
        <img src="https://source.unsplash.com/vpaHZEYx35U/800x900">
      </div>
    </figure>
    <article>
      <header class="bordered-title">
        <h1>Magna Saxa ⛰🎷</h1>
      </header>
      
      <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Aliquam, excepturi vel nesciunt facilis eum tempore autem nobis magnam iste quam dolore tenetur? Similique nemo, eligendi amet illum quia dolore ullam!</p>
      <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eligendi dolorum nihil consequatur nemo ut vel sint. Temporibus earum dolor odit? Quo beatae similique sapiente delectus iste cum rem labore porro.</p>
    </article>
  </section>

</main>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Heebo');

.img-wrap {
  transition: all .5s;
}

#app {
  font-family: Heebo, sans-serif;
  font-size: 1.5vw;
  @media (max-width: 800px) {
    font-size: 12px;
  }
  font-weight: 300;
  line-height: 1.5;
  display: grid;
  grid-template: 1 / 1;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #dfdbd2;
}

.screen {
  grid-area: 1 / 1;
}

[data-scene] {
  transition:  visibility 0s linear .8s;
  visibility: hidden;
  
  > * {
    transition: opacity .8s linear;
    opacity: 0;
  }
}


[data-state="detail"] [data-scene="detail"],
[data-state="gallery"] [data-scene="gallery"] {
  visibility: visible;
  > * { opacity: 1; } 
  //transition-delay: 0.2s; }
  transition-delay: 0s;
}


[data-state="detail"] [data-scene="gallery"]{
  .img-wrap:not([data-key]) {
    transform: translateY(100%) rotate(-20deg);
    transition-delay: calc( .2s * var(--i));
    // opacity: 0;
  }
  .img-wrap[data-key] { opacity: 0; }
}

[data-state="gallery"] [data-scene="detail"] {
  figure { opacity: 1; transition: none; }
  .img-wrap {
    opacity: 0;
  }
}

[data-state="gallery"] [data-scene="gallery"] {
  figure:first-child {
    transition: none;
  }
}


/* ---------------------------------- */

[data-scene="gallery"] {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  overflow-x: auto;

  > figure {
    flex: 0 0 auto;
    margin: 0;
    margin-left: 10vmin;

    img {
      width: 250px;
      display: block;
      max-width: 100%;
      height: auto;
      transition: transform 0.3s;
    }
  }

  .img-wrap {
    overflow: hidden;
    opacity: 1;
    z-index: 5;
    margin-bottom: 5vmin;
    img { filter: saturate(0%); transition: filter .3s linear; }
    &:hover {
      > img {
        filter: none;
      }
    }
  }
  
  
  .bordered-title {
    &::before,
    &::after {
      transform: scaleX(0);
      transition: transform 0.4s cubic-bezier(0.5, 0, 0.5, 1);
      transform-origin: left center;

      [data-state="gallery"] & {
        transform: scaleX(1);
      }
    }

    &::after {
      transition-duration: .6s;
    }
    
  }
}
/* ---------------------------------- */

[data-scene="detail"] {
  display: flex;
  justify-content: flex-start;
  align-items: center;

  > figure {
    flex: 1 0 55%;
    margin: 0;

    img {
      display: block;
      max-width: 100%;
      height: auto;
      transition: transform 0.3s;
    }
  }

  article {
    flex: 1 1 auto;
    padding: 5vmin;
  }

  .bordered-title {
    &::before,
    &::after {
      transform: scaleX(0);
      transition: transform 0.6s cubic-bezier(0.5, 0, 0.5, 1);
      transform-origin: right center;

      [data-state="detail"] & {
        transform: scaleX(1);
      }
    }

    &::after {
      transition-duration: 1s;
    }

    h1 {
      transform: translateX(50%);
      opacity: 0;

      transition: transform 0.8s cubic-bezier(0.5, 0, 0.5, 1),
        opacity 0.7s linear;

      [data-state="detail"] & {
        opacity: 1;
        transform: translateX(0);
      }
    }
  }
}

figcaption {
  font-size: 125%;
  
}

.bordered-title {
  &::before,
  &::after {
    content: "";
    display: block;
    border: solid 2px;
  }

  &::before {
    margin-bottom: 1em;
  }

  &::after {
    margin-top: 1em;
  }
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

*,
*:before,
*:after {
  box-sizing: border-box;
  position: relative; // SUE ME OKAY??
}

body,
html {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

body {
  background-color: #2b2b2b;
  display: flex;
  justify-content: center;
  align-items: center;
}

              
            
!

JS

              
                console.clear();

const losImages = document.querySelectorAll("#app");
const elApp = document.querySelector("#app");

elApp.addEventListener("click", () => {
  let elScene = document.querySelector(`[data-scene="${elApp.dataset.state}"]`);
  const elImg = elScene.querySelector('[data-key="img1"]');

  // FIRST
  const firstRect = elImg.getBoundingClientRect();

  const state = (elApp.dataset.state =
                 elApp.dataset.state === "detail" ? "gallery" : "detail");
  elScene = document.querySelector(`[data-scene="${state}"]`);

  requestAnimationFrame(() => {
    const elNextImg = elScene.querySelector('[data-key="img1"]');

    // LAST
    const lastRect = elNextImg.getBoundingClientRect();

    // INVERT
    const deltaX = firstRect.left - lastRect.left;
    const deltaY = firstRect.top - lastRect.top;
    const deltaW = firstRect.width / lastRect.width;
    const deltaH = firstRect.height / lastRect.height;

    elNextImg.style.transition = "none";
    elNextImg.style.transformOrigin = `top left`;
    elNextImg.style.transform = `translate(${deltaX}px, ${deltaY}px) scale(${deltaW}, ${deltaH})`;

    // PLAY
    requestAnimationFrame(() => {
      elNextImg.style.transition = "transform .5s cubic-bezier(.5,0,.5,1)";
      elNextImg.style.transform = "none";
    });
  });
});


setTimeout(function(){
  elApp.click();
},1500);
              
            
!
999px

Console