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

              
                <div id="slideNav">
    <ul>
      <li class="slideNavPrev">
        <a href="#" title="Go to previous slide">
          <span class="ico ico-up">↑</span>
        </a>
      </li>
      <li class="slideNavNext">
        <a href="#" title="Go to next slide">
          <span class="ico ico-down">↓</span>
        </a>
      </li>
    </ul>
  </div>
<!-- asdasd -->
<div id="slideHammer" class="slider-container">
  <div class="slides sample_01 active"><span class="textAnim">Sample 01</span></div>
  <div class="slides sample_02"><span class="textAnim">Sample 02</span></div>
  <div class="slides sample_03"><span class="textAnim">Sample 03</span></div>
  <div class="slides"><span class="textAnim">Sample 04</span></div>
  <div class="slides sample_05"><span class="textAnim">Sample 05</span></div>
</div>

<script src="https://hammerjs.github.io/dist/hammer.js"></script>

              
            
!

CSS

              
                .nav{
  position: fixed;
  z-index: 999;
  right: 30px;
  top: 30px;
  
  a{
    text-decoration: none;
    font-weight: bold;
    color: #000;
  }

}

.slider-container{
  background-color: red;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}


.slides{
  background-color: white;
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  transition: all 100ms ease;
  z-index: 1;
}

.active{
  z-index: 2;
}

.sample_01{
  background: green;
}

.sample_02{
  background: blue;
}

.sample_03{
  background: brown;
}

#slideNav {
  z-index: 5;
  position: fixed;
  right: 50px;
  top: 50%;
  width: 50px;
  -webkit-transform: translateY(-50%);
      -ms-transform: translateY(-50%);
          transform: translateY(-50%);
}
 
#slideNav ul {
  list-style: none;
  color: #ffffff;
  font-size: 13px;
  text-align: center;
  margin: 0;
  padding: 0;
}
 
#slideNav li {
  width: 50px;
  height: 50px;
  line-height: 50px;
  background-color: rgba(0, 0, 0, 0.7);
  margin-bottom: 1px;
}
 
#slideNav a {
  display: block;
  width: 50px;
  height: 50px;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: #ffffff;
}
              
            
!

JS

              
                var $activeSlide = $('.active'),
    $slides = $(".slides"),
    $slideNavPrev = $(".slideNavPrev a"),
    $slideNavNext = $(".slideNavNext a");

var $sliderContainer = $(window);
var $window = $($sliderContainer);

// Next Slider Function
function goNext(){
  var slideOut = $('.slides.active'),
      slideIn = $('.slides.active').next('.slides');

  if(slideOut.hasClass('sample_05')){
    slideIn = $('.sample_01');
    }
  
 
  
  goToNextSlide(slideOut, slideIn);
}

//Next slide
$slideNavNext.click(function (e) {
  e.preventDefault();
   goNext();
});

// Previous Slider Function

function goPrev(){
   var slideOut = $('.slides.active'),
      slideIn = $('.slides.active').prev('.slides');
 
  if(slideOut.hasClass('sample_01')){
    slideIn = $('.slides:last-child');
  }
  
  
  
  
  goToPreviousSlide(slideOut, slideIn);
}

$slideNavPrev.click(function (e) {
  e.preventDefault(); 
  goPrev();
});


function init(){

  // Hide all apart from active slide
  TweenMax.set($slides.not($activeSlide), {autoAlpha: 0});
  
}

init();

function getIndex(x){
  
    console.log(x)
  
}

var currentAnimation;
var requestedAnimation;
var checkStats = 'a';

function playRequestedAnimation() {
  requestedAnimation.play();
  checkStats = 'b';
  currentAnimation = requestedAnimation;
}

// 

function gNext(slideOut,slideIn){
      var tl = new TimelineLite({paused:true,onReverseComplete:playRequestedAnimation});
//   

          tl.to($slideNavPrev,1,{y:200,ease:Power0.easeNone},'skipThem')
            .to(slideIn,1,{autoAlpha: 1, className: '+=active'}, "skipActive")
            .to(slideOut,1, {className: '-=active'}, "skipActive");
          this.animation = tl;
          

          



}

function goToNextSlide(slideOut, slideIn){

    if(slideIn.length !== 0){
    
      gNext(slideOut,slideIn);
      
      requestedAnimation = this.animation;
      
      if(currentAnimation){
        currentAnimation.reverse(-2);
        
      } else {
        
        playRequestedAnimation()
      }
      
      
    } 

    
    

}

function goToPreviousSlide(slideOut, slideIn){
  
  var tl = new TimelineMax();
  
  if(slideIn.index() >= 0){
    
    tl
      .set(slideIn, {autoAlpha: 1, className: '+=active'})
      .set(slideOut, {className: '-=active'});
    // .to(slideOut, 0.5, {y: '110%', ease:Power3.easeInOut}, 0)
    // .to(slideIn, 0.5, {y: '+=110%', ease:Power3.easeInOut}, '-=0.5')
  
  } 
  
  getIndex(slideIn.index());

}



var element = document.getElementById("slideHammer"); 
			var mc = new Hammer(element);
			mc.get('swipe').set({ direction: Hammer.DIRECTION_ALL });

			mc.on("swipeleft", function () { 
          console.log('swipe left triggered')
			}); 
          
      mc.on("swiperight", function () { 
        console.log('swipe right triggered')
			});
			
			mc.on("swipeup", function () { 
				goNext();
			}); 
			
			mc.on("swipedown", function () { 
        goPrev();
			});


$window.on("wheel", _.debounce(onMouseWheel1, 200,{
  leading: false
}));

function onMouseWheel1(event) {
  if(event.originalEvent.deltaY < 0) {
      goPrev();
  } else {
      goNext();
  }
}
              
            
!
999px

Console