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 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

              
                <main class="mainContent home">

  <section id="section1_sec" class="home__section" data-sec="1">
    <img style="width:100%; height:100vh; object-fit: cover;" src="//vincentvtoscano.github.io/PinnedExperience_2020/assets/imgs/home/PinnedExperience_earth-1920x1080-50.jpg">
  </section>

  <section id="section2_sec" class="home__section" data-sec="2">
    <img style="width:100%; height:100vh; object-fit: cover;" src="//vincentvtoscano.github.io/PinnedExperience_2020/assets/imgs/home/PinnedExperience_water-1920x1080-50.jpg">
  </section>

  <section id="section3_sec" class="home__section" data-sec="3">
    <img style="width:100%; height:100vh; object-fit: cover;" src="//vincentvtoscano.github.io/PinnedExperience_2020/assets/imgs/home/PinnedExperience_fire-1920x1080-50.jpg">
  </section>

  <section id="section4_sec" class="home__section" data-sec="4">
    <img style="width:100%; height:100vh; object-fit: cover;" src="//vincentvtoscano.github.io/PinnedExperience_2020/assets/imgs/home/PinnedExperience_air-1920x1080-50.jpg">
  </section>

  <section id="section5_sec" class="home__section" data-sec="5">
    <img style="width:100%; height:100vh; object-fit: cover;" src="//vincentvtoscano.github.io/PinnedExperience_2020/assets/imgs/home/PinnedExperience_void-1920x1080-50.jpg">
  </section>
  <div id="lens1_lens" class="home__lens"></div>
</main>

<div class="demo__marker"></div>
              
            
!

CSS

              
                // Media queries
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
$media-rules: (
  mobile: "(max-width: 719px)",
  tablet: "only screen and (min-width: 720px) and (max-width: 959px)",
  desktop: "only screen and (min-width: 960px) and (max-width: 1199px)",
  tablet-width-min: 720px,
  desktop-width-min: 960px
);

/*
9/10/20 For mobile I am now going to desktop-width-min over the tablet-width-min
This is due to the fact that we only support 2 breakpoints
*/
@mixin mobile {
  @media (max-width: #{ map_get($media-rules, desktop-width-min) - 1px}) {
    @content;
  }
}
//  Expected box layout model to all elements
*,
*:before,
*:after {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
// Border Radius
@mixin borderRadius($radius: 5px) {
  -webkit-border-radius: $radius;
  -moz-border-radius: $radius;
  border-radius: $radius;
}

// Opacity
@mixin opacity($opacity: 1) {
  -moz-opacity: $opacity;
  -ms-opacity: $opacity;
  -o-opacity: $opacity;
  -webkit-opacity: $opacity;
  opacity: $opacity;
}

.demo__marker {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 100vw;
  height: 3px;
  background: black;
}

.home {
  .home__section {
    position: relative;
    width: 100%;
    height: 100vh;
    background-color: grey;
    overflow: hidden;

    // Change color of backgrounds for demo purposes
    $chartColors: #1c3a13, #f76540, #ffcb05, #62cd9f, #b67baa;

    @for $i from 1 through length($chartColors) {
      $chartColors: append($chartColors, darken(nth($chartColors, $i), 25));
    }
    $chartColorsLength: length($chartColors);

    @for $i from 1 through $chartColorsLength {
      &:nth-of-type(#{$chartColorsLength}n + #{$i}) {
        background-color: nth($chartColors, $i);

        &:before {
          font-size: 20px;
          font-weight: 700;
          //content: 'Slide #{($i)} | #{nth($chartColors, $i)}';
          text-align: center;
          //background: rgba(255, 255, 255, 0);
          display: block;
        }
      }
    }
  }

  .home__lens {
    z-index: 100;
    position: fixed;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    background: radial-gradient(
      50% 50% at 50% 50%,
      rgba(8, 18, 42, 0.02) 0%,
      rgba(255, 255, 255, 0.13) 90%,
      rgba(8, 40, 42, 0.8) 100%
    );
    overflow: hidden;
    transform: translate(-50%, -50%);
    @include opacity(0.88);
    @include borderRadius(50%);
    mix-blend-mode: normal;

    @include mobile {
      background: radial-gradient(
        50% 50% at 50% 50%,
        rgba(8, 18, 42, 0.02) 0%,
        rgba(255, 255, 255, 0.13) 90%,
        rgba(8, 18, 42, 0.8) 100%
      );
      width: 262px;
      height: 262px;
    }
  }
}

              
            
!

JS

              
                // ▒ PinnedExperience --- Main entry point
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

//  Global vars
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
const NAME = "PinnedExperience >";

let bdy, main, footer, mobileNav;
//  Utility
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
/**
 * _id --- Grab element by ID.
 * @param id
 * @returns {HTMLElement}
 */
let _id = function (id) {
  return document.getElementById(id);
};

//  Application
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
/**
 * init --- Initialize application.
 */
PinnedExperience.init = function () {
  bdy = document.body;
  main = document.getElementsByTagName("main")[0];
  footer = document.getElementsByTagName("footer");

  window.addEventListener("resize", PinnedExperience.onResize);
  PinnedExperience.onResize();

  gsap.set("#lens1_lens", { xPercent: -50, yPercent: -50 });

  PinnedExperience.enactPinning();
};

PinnedExperience.enactPinning = function () {
  gsap.registerPlugin(ScrollTrigger);

  gsap.to("#lens1_lens", {
    x: "+=225",
    duration: 12,
    scrollTrigger: {
      trigger: "#section2_sec",
      toggleActions: "none pause reverse pause",
      start: "top top+=75%",
      end: "bottom bottom",
      scrub: true,
      markers: true
    }
  });

  gsap.to("#lens1_lens", {
    immediateRender: false,
    x: "-=500",
    duration: 2,
    scrollTrigger: {
      trigger: "#section3_sec",
      toggleActions: "none pause reverse pause",
      start: "top top+=75%",
      // stop: "bottom top",
      scrub: true,
      end: "bottom bottom",
      markers: true
    }
  });
};

PinnedExperience.onResize = function (evt) {
  let winHeight =
    window.innerHeight ||
    document.documentElement.clientHeight ||
    document.body.clientHeight;
  console.log(winHeight);
};

PinnedExperience.init();

              
            
!
999px

Console