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

              
                <nav class="centered"></nav>

<svg class="go go-next" width="32" height="55" viewBox="0 0 40 55">
  <polyline points="3 3 30 28 3 53"></polyline>
</svg>

<svg class="go go-prev" viewBox="0 0 40 55">
  <polyline points="28 3 3 28 28 53"></polyline>
</svg>

<div class="slides-container">

  <div class="slide active" id="slide01">
    <h1 class="lines">An APPLE per day<br>
      keeps the code clean!</h1>
  </div>

  <div class="slide" id="slide02">

    <img class="apple apple01 centered" src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/174563/apple.png' alt=''>
    <img class="apple apple02 centered" src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/174563/apple.png' alt=''>

    <div class="wrap centered">
      <h1 class="lines">Two APPLES per day ...<br>
        you become a MASTER!</h1>
    </div>

  </div>

  <div class="slide" id="slide03">
    <h1 class="lines">And you'll get <span>GREEN</span> socks</br>
      for faster CODING!</h1>
  </div>

  <div class="slide" id="slide04">
    <h1 class="lines">Join the GREENSOCK Club.</h1>
  </div>
 <div class="slide" id="slide05">
   
   
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
   
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
    
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
   
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br><br><br><br>
  </div>
</div>

              
            
!

CSS

              
                body,
div,
p {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
}

.go {
  width: 25px;
  stroke: #636363;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  z-index: 12;
}
.go-prev,
.go-next {
  position: absolute;
  cursor: pointer;
  top: 50%;
  left: 5px;
}
.go-next {
  left: calc(100% - 32px);
}
h1 {
  position: absolute;
  top: 50%;
  width: 100%;
  font-weight: 800;
  font-size: 36px;
  margin: 0;
}
nav {
  position: absolute;
  bottom: 10px;
  left: 50%;
  width: inherit;
  z-index: 100;
  visibility: hidden;
}
.navDot {
  position: relative;
  width: 15px;
  height: 15px;
  background-color: black;
  opacity: 0.5;
  border-radius: 50%;
  border: 1px solid transparent;
  margin-right: 20px;
  float: left;
  cursor: pointer;
}
.navDot:last-of-type {
  margin-right: 0px;
}
.navDot:hover {
  background-color: green;
  border: 1px solid black;
}

.slides-container {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  z-index: 10;
}

.slide {
  position: absolute;
  top: 0;
  left: 100%;
  width: 100%;
  height: 100%;
  text-align: center;
  background-color: grey;
  overflow: hidden;
}

#slide02 .wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  text-align: center;
  height: 100px;
  overflow: hidden;
}
#slide02 h1 {
}
.apple01 {
  position: absolute;
  top: 56%;
  left: 40%;
  width: 160vh;
}
.apple02 {
  position: absolute;
  top: 58%;
  left: 58%;
  width: 160vh;
}

#slide05{
  overflow-y: auto;
}
              
            
!

JS

              
                console.clear();

//  =============  xxxxx  ==========================

gsap.set(".centered", { autoAlpha: 1, xPercent: -50, yPercent: -50 });
gsap.set("h1", { autoAlpha: 1, yPercent: -50 });
gsap.set(" .slide", { autoAlpha: 1, xPercent: 0 });
gsap.set(".go", { autoAlpha: 1, yPercent: -50 });

var slides = $(".slide"),
  activeSlide = $(".slide.active"),
  next = $(".go-next"),
  prev = $(".go-prev"),
  moveSlideTL = gsap.timeline(),
  lines = $("h1");

// individual animations per slide ======

const allSlides = [].slice.call(slides);
let animations = [];

for (let [i] of allSlides.entries()) {
  animations[i] = gsap.timeline({});
}

animations[0]
  .from("#slide01 .lines", { y: 30, autoAlpha: 0, duration: 1, delay: 0.5 })
  .reverse();

animations[1]
  .from(".apple", {
    xPercent: -200,
    duration: 0.6,
    ease: "elastic.out(0.5, 0.4)",
    stagger: -0.4
  })
  .from("#slide02 .lines", { y: 120, duration: 1, delay: 1 }, "-=1.5")
  .reverse();

animations[2]
  .from("#slide03 .lines", { y: 30, autoAlpha: 0, duration: 1 })
  .set("#slide03 span", { color: "green" })
  .reverse();

animations[3]
  .from("#slide04 .lines", {
    scale: 0.2,
    transformOrigin: "center",
    duration: 2
  })
  .reverse();

// ===========================

$(".slides-container").swipe({
  swipe: function (event, direction) {
    if (direction === "left") {
      if (!moveSlideTL.isActive()) {
        if (!moveSlideTL.isActive()) {
          var slideFrom = $(".slide.active"),
            sectionToIndex = slides.index(slideFrom);

          if (sectionToIndex != 0) {
            slideTo = slides.eq(sectionToIndex - 1);
            moveToSlide(slideFrom, slideTo);
          }
        }
      }
    } else {
      if (!moveSlideTL.isActive()) {
        var slideFrom = $(".slide.active"),
          sectionToIndex = slides.index(slideFrom);

        if (sectionToIndex !== slides.length - 1) {
          slideTo = slides.eq(sectionToIndex + 1);
          moveToSlide(slideFrom, slideTo);
        }
      }
    }
  }
});

//==============================

function onMouseWheel(event) {
  //Normalize event wheel delta
  var delta =
    event.originalEvent.wheelDelta / 30 || -event.originalEvent.detail;

  if (delta < -1) {
    //scrolling down -> next slide
    if (!moveSlideTL.isActive()) {
      var slideFrom = $(".slide.active"),
        sectionToIndex = slides.index(slideFrom);

      if (sectionToIndex !== slides.length - 1) {
        slideTo = slides.eq(sectionToIndex + 1);
        moveToSlide(slideFrom, slideTo);
      }
    }
  } else if (delta > 1) {
    // -> prev
    if (!moveSlideTL.isActive()) {
      if (!moveSlideTL.isActive()) {
        var slideFrom = $(".slide.active"),
          sectionToIndex = slides.index(slideFrom);

        if (sectionToIndex != 0) {
          slideTo = slides.eq(sectionToIndex - 1);
          moveToSlide(slideFrom, slideTo);
        }
      }
    }
  }
  //event.preventDefault();
}

// ============================
function dotClick() {
  var slideFrom = $(".slide.active"),
    sectionToIndex = $(this).index(),
    sectionToIndex = $(this).index(),
    slideTo = slides.eq(sectionToIndex);

  var indexFrom = slideFrom.index();

  console.log(
    slideFrom,
    "from: " + indexFrom,
    "to: " + sectionToIndex,
    "slideTo: " + slideTo
  );

  //if(slideFrom !== slideTo && !moveSlideTL.isActive()) {  // not working

  if (indexFrom !== sectionToIndex && !moveSlideTL.isActive()) {
    moveToSlide(slideFrom, slideTo);
  }
}

// =============================
function nextClick() {
  if (!moveSlideTL.isActive()) {
    var slideFrom = $(".slide.active"),
      sectionToIndex = slides.index(slideFrom);

    if (sectionToIndex !== slides.length - 1) {
      slideTo = slides.eq(sectionToIndex + 1);
      moveToSlide(slideFrom, slideTo);
    }
  }
}

function prevClick() {
  if (!moveSlideTL.isActive()) {
    var slideFrom = $(".slide.active"),
      sectionToIndex = slides.index(slideFrom);

    if (sectionToIndex != 0) {
      slideTo = slides.eq(sectionToIndex - 1);
      moveToSlide(slideFrom, slideTo);
    }
  }
}

// ==============================
function moveToSlide(slideFrom, slideTo) {
  gsap.set(".go", { autoAlpha: 0 }); // ????

  if (slides.index(slideFrom) < slides.index(slideTo)) {
    // vorwärts

    moveSlideTL = gsap
      .timeline({
        onComplete: setActiveSlide,
        onCompleteParams: [slideTo, slideFrom]
      })
      .to(slideTo, { xPercent: -100, duration: 0.8, className: "slide active" })
      .to(slideFrom, { xPercent: -200, duration: 0.8, className: "slide" }, 0)
      .set(slideFrom, { xPercent: 0 });
  } else {
    moveSlideTL = gsap
      .timeline({
        onComplete: setActiveSlide,
        onCompleteParams: [slideTo, slideFrom]
      })
      .set(slideTo, { xPercent: -200, className: "slide active" })
      .to(slideTo, { xPercent: -100, duration: 0.8 })
      .to(slideFrom, { xPercent: 0, duration: 0.8, className: "slide" }, 0);
  }
}

function setActiveSlide(active, last) {
  var currentSlideIndex = slides.index(active);
  var lastSlideIndex = slides.index(last);

  animations[currentSlideIndex].reversed(false);
  animations[lastSlideIndex].progress(0).reversed(true);

  gsap.to(".navDot.active", { opacity: 0.5, scale: 1 });
  $(".navDot.active").removeClass("active");
  $(".navDot").eq(currentSlideIndex).addClass("active");
  gsap.to(".navDot.active", { opacity: 1, scale: 1.3 });

  if (currentSlideIndex == 0) {
    gsap.set(".go-prev", { autoAlpha: 0 });
  } else {
    gsap.set(".go-prev", { autoAlpha: 1 });
  }
  if (currentSlideIndex == slides.length - 1) {
    gsap.set(".go-next", { autoAlpha: 0 });
  } else {
    gsap.set(".go-next", { autoAlpha: 1 });
  }
}

// ================================
function init() {
  for (var i = 0; i < slides.length; i++) {
    var navDots = $("<div></div>").addClass("navDot").appendTo("nav");
    gsap.set(".navDot:first-child", {
      className: "navDot active",
      opacity: 1,
      scale: 1.3,
      transformOrigin: "center"
    });
    navDots.on("click", dotClick);
  }

  if (slides[0]) {
    gsap.set(".go-prev", { autoAlpha: 0 });
  }

  next.on("click", nextClick);
  prev.on("click", prevClick);

  $(window).on("mousewheel DOMMouseScroll", onMouseWheel);
  //$(window).on("touchmove", onMouseWheel);

  gsap.set($(".slide:odd"), { backgroundColor: "#0f8c0d", color: "#333333" });
  gsap.set(".slide.active", { xPercent: -100 });
  animations[0].reversed(false);
}

init();

              
            
!
999px

Console