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

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

              
                <div class="hideMe">

    <svg id="leftArrow" class="arrow" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
        <g stroke-linejoin="round" stroke-linecap="round" >
            <circle r="46" cx="50" cy="50" />
            <polyline points="60 25, 30 50, 60 75" ></polyline>
        </g>
    </svg>

    <svg id="rightArrow" class="arrow" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
        <g stroke-linejoin="round" stroke-linecap="round" >
            <circle r="46" cx="50" cy="50" />
            <polyline points="40 25, 70 50, 40 75" ></polyline>
        </g>
    </svg>

    <div id="masterWrap">

      <div id="panelWrap">

        <section class="section">

            <a href="" class="img-gradient">
              <div class="section--text">01</div>
              <img src="https://picsum.photos/600/800?random=1">
            </a>
    
        </section>
    
        <section class="section">
    
            <a href="" class="img-gradient">
              <div class="section--text">02</div>
              <img src="https://picsum.photos/600/800?random=2">
            </a>
    
        </section>
    
        <section class="section">
    
            <a href="" class="img-gradient">
              <div class="section--text">03</div>
              <img src="https://picsum.photos/600/800?random=3">
            </a>
    
        </section>
    
        <section class="section">
    
            <a href="" class="img-gradient">
              <div class="section--text">04</div>
              <img src="https://picsum.photos/600/800?random=4">
            </a>
    
        </section>
    
        <section class="section">
    
            <a href="" class="img-gradient">
              <div class="section--text">05</div>
              <img src="https://picsum.photos/600/800?random=5">
            </a>
    
        </section>
    
        <section class="section">
    
            <a href="" class="img-gradient">
              <div class="section--text">06</div>
              <img src="https://picsum.photos/600/800?random=6">
            </a>
    
        </section>
    
        <section class="section">
    
            <a href="" class="img-gradient">
              <div class="section--text">07</div>
              <img src="https://picsum.photos/600/800?random=7">
            </a>
    
        </section>
    
        <section class="section">
    
            <a href="" class="img-gradient">
              <div class="section--text">08</div>
              <img src="https://picsum.photos/600/800?random=8">
            </a>
          
        </section>
    
        <section class="section">
    
            <a href="" class="img-gradient">
              <div class="section--text">09</div>
              <img src="https://picsum.photos/600/800?random=9">
            </a>
    
        </section>
    
        <section class="section">
    
            <a href="" class="img-gradient">
              <div class="section--text">10</div>
              <img src="https://picsum.photos/600/800?random=10">
            </a>
    
        </section>
    
        <section class="section">
    
            <a href="" class="img-gradient">
              <div class="section--text">11</div>
              <img src="https://picsum.photos/600/800?random=11">
            </a>
    
        </section>

      </div>

    </div>

</div>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

body {
  padding: 0;
  margin: 0;
  font-family: "Acumin", sans-serif, Arial;
  color: white;
  overflow: hidden;
  height: 100%;
  width: 100%;
}

#masterWrap {
  width: 100%;
  height: 100%;
  position: absolute;
  overflow: hidden;
}

#panelWrap {
  height: 100%;
  display: flex;
  flex-wrap: nowrap;
  position: fixed;
}

/*
.wrapper {
        display: flex;
        flex-wrap: nowrap;
        position: fixed;
    }

    .section {
        display: flex;
        flex-shrink: 0;
        height: 100vh;
        justify-content: center;
        align-items: center;
        overflow: hidden;
        position: relative;
        width: 33.33vw;
        font-size: 30px;
    }
*/

section {
  height: 100%;
  display: flex;
  flex-shrink: 0;
  align-content: center;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  overflow: hidden;
  position: relative;
  /* float: left; */
  width: 33.33vw;
  background-color: #0f0;
}

@media only screen and (max-width: 1023px) and (min-width: 561px) {
  #panelWrap {
    width: 100%;
  }
  section {
    width: 100vw;
  }
}
section img {
    height: 100vh;
}
section .img-gradient {
    display: inline-block;
    height: 100%;
}
section .img-gradient:after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: inline-block;
    background: -moz-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 50%, black 100%);
    /* FF3.6-15 */
    background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 50%, black 100%);
    /* Chrome10-25,Safari5.1-6 */
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 50%, black 100%);
    /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00000000', endColorstr='#000000',GradientType=0 );
    /* IE6-9 */
}
.section--text {
    position: absolute;
    top: 70%;
    left: 5%;
    width: 75%;
    z-index: 99;
    color: #fff;
}

.section--text h2 {
    font-size: 40px;
    font-weight: 700;
    letter-spacing: -0.05em;
    margin: 0;
}
.section--text h2 span {
    opacity: 0.75;
    font-weight: 400;
}
.section--text p {
    font-size: 16px;
    font-weight: 300;
    line-height: 1.48;
    opacity: 0;
}



#leftArrow {
  left: 12px;
  margin-left: 30px;
}

#rightArrow {
  right: 12px;
  margin-right: 30px;
}

.arrow {
  position: absolute;
  z-index: 100;
  bottom: 30px;
  cursor: pointer;
  opacity: 0.75;
  width: 40px;
  height: 40px;
  stroke-width: 8px;
  stroke: white;
  fill: transparent;
}


.hideMe {
  opacity: 0;
}
              
            
!

JS

              
                console.clear();

const colorArray = [
  "#683A5E",
  "#262626",
  "#426F42",
  "#8B814C",
  "#36648B",
  "#683A5E",
  "#262626",
  "#426F42",
  "#8B814C",
  "#36648B",
  "#683A5E",
  "#262626"
];


const slides = document.querySelectorAll("section");
const container = document.querySelector("#panelWrap");
let dur = 0.5;
let offsets = [];
let oldSlide = 0;
let activeSlide = 0;
let iw = window.innerWidth;

document.querySelector("#leftArrow").addEventListener("click", slideAnim);
document.querySelector("#rightArrow").addEventListener("click", slideAnim);

// set slides background colors
for (let i = 0; i < slides.length; i++) {
  gsap.set(slides[i], { backgroundColor: colorArray[i] });
}

// get elements positioned
gsap.set(".arrow", { yPercent: -50 });

// make the whole thing draggable
let dragMe = Draggable.create(container, {
  type: "x",
  edgeResistance: 1,
  //snap: offsets,
  inertia: true,
  bounds: "#masterWrap",
  onDragEnd: slideAnim,
  allowNativeTouchScrolling: false,
  zIndexBoost: false
});

dragMe[0].id = "dragger";
sizeIt();

// main action check which of the 3 types of interaction called the function
function slideAnim(e) {
  oldSlide = activeSlide;
  // dragging the panels
  if (this.id === "dragger") {
    activeSlide = offsets.indexOf(this.endX);
    console.log ("(this.endX) = " + (this.endX));
    console.log ("id === dragger -- offsets.indexOf(this.endX) = " + offsets.indexOf(this.endX));
  } else {
    if (gsap.isTweening(container)) {
      return;
    }
    // arrow clicks
    if (this.id === "leftArrow" || this.id === "rightArrow") {
      activeSlide = this.id === "rightArrow" ? (activeSlide += 3) : (activeSlide -= 3);
      dur = 1;
      // scrollwheel
    } else {
      activeSlide = e.deltaY > 0 ? (activeSlide += 1) : (activeSlide -= 1);
      dur = 0.6;
      console.log ("e.deltaY = " + e.deltaY)
    }
  }
  // make sure we're not past the end or beginning slide
  activeSlide = activeSlide < 0 ? 0 : activeSlide;
  activeSlide = activeSlide > slides.length - 3 ? slides.length - 3 : activeSlide;
  if (oldSlide === activeSlide) {
    return;
  }
  // if we're dragging we don't animate the container
  if (this.id != "dragger") {
    gsap.to(container, dur, { 
      x: offsets[activeSlide],
      ease: "power2.out"
    });
    console.log ("id != dragger -- offsets[activeSlide] = " + offsets[activeSlide]);
  }
}

// update the draggable element snap points
function sizeIt() {
  offsets = [];
  iw = window.innerWidth;
  //gsap.set("#panelWrap", { width: slides.length * (iw * 0.3333)});
  //gsap.set(slides, { width: iw * 0.3333 });
  for (let i = 0; i < slides.length; i++) {
    offsets.push(-slides[i].offsetLeft);
  }
  gsap.set(container, { x: offsets[activeSlide] });
  dragMe[0].vars.snap = offsets;
}

gsap.set(".hideMe", { opacity: 1 });
window.addEventListener("wheel", slideAnim);
window.addEventListener("resize", sizeIt);
              
            
!
999px

Console