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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <nav>
  <ul>
    <li><a href="#slide-1" id="Slide01" class="active">Slide 1</a></li>
    <li><a href="#slide-2" id="Slide02">Slide 2</a></li>
    <li><a href="#slide-3" id="Slide03">Slide 3</a></li>
    <li><a href="#slide-4" id="Slide04">Slide 4</a></li>
  </ul>
</nav>

<div class="slides-container">
  <div class="slide active" id="slide-1">
    <div class="centered">
      <div id="action1" class="action centered"></div>
      <h1>Fullscreen slides with GSAP</h1>      
    </div>
  </div>
  <div class="slide" id="slide-2">
    <div id="action2" class="action centered"></div>
  </div>
  <div class="slide" id="slide-3">
    <div class="centered">
      <div id="action3" class="action centered"></div>
      <h1>Use mouse wheel</h1>      
    </div>
  </div>
  <div class="slide" id="slide-4">
    <div class="centered">
      <div id="action4" class="action centered"></div>
      <h1>... Or use keyboard arrows</h1>      
    </div>
  </div>
</div>
              
            
!

CSS

              
                body, div, p {
    margin: 0;
    padding: 0;
}

body {
    font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
    font-weight: 300;
    letter-spacing: 0.0625em;
}

a {
    text-decoration: none;
}

nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
}

nav ul {
    list-style: none;
    text-align: center;
    margin-top: 30px;
}

nav ul li {
    display: inline-block;
    margin-right: 20px;
}

nav ul li:last-child {
    margin-right: 0;
}

#back-to-tutorial {
    margin-left: 100px;
}

nav a {
    position: relative;
    top: 0;
    padding: 10px 20px;
    font-weight: normal;
    font-size: 20px;
    text-align: center;
    border-radius: 4px;
    background-color: #FFFFFF;
    color: #83C78E;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
}

nav a.active {
    top: -4px;
    background-color: #69C773;
    color: #FFFFFF;
    -webkit-box-shadow: 0 4px 0 0 #51a65f;
    -moz-box-shadow: 0 4px 0 0 #51a65f;
    box-shadow: 0 4px 0 0 #51a65f;
}

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

.slide {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.slide .centered {
    position: absolute;
    width: 100%;
    top: 50%;
    left: 50%;
	visibility: hidden;
}

.slide .centered h1 {
    text-align: center;  
}

.slide .centered p {
    text-align: center;
    margin-top: 20px;
    font-size: 20px;
}

#slide-1 {
    background-color: #FFFFFF;
}

#slide-2 {
    background-color: #45959b;
}

#slide-3 {
    background-color: #778899;
}

#slide-4 {
    color: #FFFFFF;
    background-color: #291F37;
}

.go-prev, .go-next {
    cursor: pointer;
    font-weight: bold;
    text-decoration: underline;
}

.action {
	position: absolute;
	left:50%; top:50%;
	width: 200px !important; height: 200px;
	background: red;
}


              
            
!

JS

              
                window.onload = function() {
  //  =============  xxxxx  ==========================	

  TweenMax.set(".centered", {autoAlpha: 1, xPercent:-50, yPercent:-50, force3D:true});	


  //Forked from [Chrysto](https://codepen.io/bassta/)'s Pen [Fullscreen slides with TweenLite, CSSPlugin and ScrollToPlugin](https://codepen.io/bassta/pen/kDvmC/).

  //First the variables our app is going to use need to be declared

  //References to DOM elements
  var $window = $(window);
  var $document = $(document);
  //Only links that starts with #
  var $navButtons = $("nav a").filter("[href^=#]");
  var $navGoPrev = $(".go-prev");
  var $navGoNext = $(".go-next");
  var $slidesContainer = $(".slides-container");
  var $allSlides = $(".slide");
  var $currentSlide = $allSlides.first();
  var slideControl = $("nav a")


  //Animating flag - is our app animating
  var isAnimating = false;

  //The height of the window
  var pageHeight = $window.innerHeight();

  //Key codes for up and down arrows on keyboard. We'll be using this to navigate change slides using the keyboard
  var keyCodes = {
    UP  : 38,
    DOWN: 40
  };


  var currentIndex = 0;
  
  var timeline1 = new TimelineLite()
    .to("#action1", 2, {scale: 2})
    .reverse();
  
  var timeline2 = new TimelineLite()
    .to("#action2", 2, {scale: 2})
    .reverse();
  
  var timeline3 = new TimelineLite()
    .to("#action3", 2, {scale: 2})
    .reverse();
  
  var timeline4 = new TimelineLite()
    .to("#action4", 2, {scale: 2})
    .reverse();

  var timelines = [timeline1, timeline2, timeline3, timeline4];
  
  //Going to the first slide
  goToSlide($currentSlide);
  //TweenLite.set($currentSlide, {className: "+=active"});

  /*
	*   Adding event listeners
	* */

  $window.on("resize", onResize).resize();
  $window.on("mousewheel DOMMouseScroll", onMouseWheel);
  $document.on("keydown", onKeyDown);
  $navButtons.on("click", onNavButtonClick);
  $navGoPrev.on("click", goToPrevSlide);
  $navGoNext.on("click", goToNextSlide);

  /*
	*   Internal functions
	* */


  /*
	*   When a button is clicked - first get the button href, and then slide to the container, if there's such a container
	* */
  function onNavButtonClick(event)
  {
    //The clicked button
    var $button = $(this);

    //The slide the button points to
    var $slide = $($button.attr("href"));

    //If the slide exists, we go to it
    if($slide.length)
    {
      goToSlide($slide);
      event.preventDefault();
    }
  }

  /*
	*   Getting the pressed key. Only if it's up or down arrow, we go to prev or next slide and prevent default behaviour
	*   This way, if there's text input, the user is still able to fill it
	* */
  function onKeyDown(event)
  {

    var PRESSED_KEY = event.keyCode;

    if(PRESSED_KEY == keyCodes.UP)
    {
      goToPrevSlide();
      event.preventDefault();
    }
    else if(PRESSED_KEY == keyCodes.DOWN)
    {
      goToNextSlide();
      event.preventDefault();
    }

  }

  /*
	*   When user scrolls with the mouse, we have to change slides
	* */
  function onMouseWheel(event)
  {
    //Normalize event wheel delta
    var delta = event.originalEvent.wheelDelta / 30 || -event.originalEvent.detail;

    //If the user scrolled up, it goes to previous slide, otherwise - to next slide
    if(delta < -1)
    {
      goToNextSlide();
    }
    else if(delta > 1)
    {
      goToPrevSlide();
    }

    event.preventDefault();


  }

  /*
	*   If there's a previous slide, slide to it
	* */
  function goToPrevSlide()
  {
    if($currentSlide.prev().length)
    {
      goToSlide($currentSlide.prev());
    }
  }

  /*
	*   If there's a next slide, slide to it
	* */
  function goToNextSlide()
  {
    if($currentSlide.next().length)
    {
      goToSlide($currentSlide.next());
    }
  }




  /*
	*   Actual transition between slides
	* */
  function goToSlide($slide)
  {
    //If the slides are not changing and there's such a slide
    if(!isAnimating && $slide.length)
    {
      //setting animating flag to true
      isAnimating = true;
      $currentSlide = $slide;
      NextSlide = $currentSlide.next()           

      //Sliding to current slide
      TweenLite.to($slidesContainer, 1, {scrollTo: {y: pageHeight * $currentSlide.index() }, onComplete: onSlideChangeEnd, onCompleteScope: this});

      //Definig slide status
      TweenLite.to($allSlides.filter(".active"), 0.1, {className: "-=active"});
      TweenLite.to($allSlides.filter($currentSlide), 0.1, {className: "+=active"});

      //Animating menu items
      TweenLite.to($navButtons.filter(".active"), 0.5, {className: "-=active"});
      TweenLite.to($navButtons.filter("[href=#" + $currentSlide.attr("id") + "]"), 0.5, {className: "+=active"});

      //console.log(anim02);  
      console.log($navButtons);
      console.log($allSlides);		
    }
  }



  /* ============ animations individual / slide ===================*/

  //var anim02 = $("#slide-2").hasClass('.active');
  //var anim02 = $("#slide02").hasClass('.active');

  //var T02 = new TimelineLite({paused:true});
  //T02.to(".action02", 2, {scale: 2});	

  /* ============ animations End===================*/


  /*
	*   Once the sliding is finished, we need to restore "isAnimating" flag.
	*   You can also do other things in this function, such as changing page title
	* */
  function onSlideChangeEnd() {
    isAnimating = false;
    
    // Reverse the timeline for the previous slide
    timelines[currentIndex].reversed(true).progress(0);
    
    // Change the index
    currentIndex = $currentSlide.index();
    
    // Play the timeline for the current slide
    timelines[currentIndex].reversed(false);
  }

  /*
	*   When user resize it's browser we need to know the new height, so we can properly align the current slide
	* */
  function onResize(event)
  {

    //This will give us the new height of the window
    var newPageHeight = $window.innerHeight();

    /*
		*   If the new height is different from the old height ( the browser is resized vertically ), the slides are resized
		* */
    if(pageHeight !== newPageHeight)
    {
      pageHeight = newPageHeight;

      //This can be done via CSS only, but fails into some old browsers, so I prefer to set height via JS
      TweenLite.set([$slidesContainer, $slides], {height: pageHeight + "px"});

      //The current slide should be always on the top
      TweenLite.set($slidesContainer, {scrollTo: {y: pageHeight * $currentSlide.index() }});
    }

  }
}
              
            
!
999px

Console