css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .slide1.slide
  h1 REALLY COOL SLIDER
  h2 just scroll to try it
.slide2.slide
  h1 2
.slide3.slide
  h1 3
.slide4.slide
  h1 4
.slide5.slide
  h1 5
  
.controls
  .left
  .right
            
          
!
            
              *
  box-sizing: border-box

.bottom
  position: fixed
  bottom: 0
  color: white
  z-index: 50
  left: 50%
  transform: translateX(-50%)
  -moz-transform: translateX(-50%)
  
  h3
    font-weight: 300

body
  margin: 0
  background: #262625
  width: 100vw
  height: 100vh
  overflow: hidden

div[class^="slide"]
  display: flex
  justify-content: center
  align-items: center
  flex-direction: column
  width: 100vw
  height: 100vh
  left: 100vw
  transform: scale(.8)
  -moz-transform: scale(.8)
  position: absolute
  
.slide1
  background: #FF6961
  color: white
  
  img
    height: 30px
    transform: rotate(-90deg)
    -moz-transform: rotate(-90deg)
    
  .img2
    height: 30px
    margin-top: 40px
    transform: rotate(90deg)
    -moz-transform: rotate(90deg)
    
  
  h2
    margin: -20px
    color: #ae4742
  
.slide2
  background: #FDFD96
  color: #b2b26d
  
.slide3
  background: #77DD77
  color: #519651
  
.slide4
  background: #779ECB
  color: #536f90
  
.slide5
  background: #FFD1DC
  color: #b49098
  	
  	
            
          
!
            
              $(document).ready(function() {
  
  var count = $('[class^="slide"]').size();
  var lastScrollTop = 0;
  var prev = count;
  var curr = 1;
  var now = 8;
  var next = 2;
  var finished = true;

  $('.slide' + curr).css("left","0");
  $('.slide' + curr).css("transform","scale(1)");
  $('.slide').on('mousewheel DOMMouseScroll MozMousePixelScroll', function (e) {
    if (finished) {
      finished = false;
      var delta = e.originalEvent.wheelDelta;
      console.log(delta);
      
      if (delta < 0) {
        $('[class^="slide"]').css("transition","all 0.5s ease, width 0s, height 0s");
        $('.slide' + curr).css("transform","scale(.8)");
        $('.slide' + curr).animate({
            step: function(now,fx) {
              $(this).css('transform',"scale(."+now+")");
            },
            duration:'slow'
        },'linear');
        $('.slide' + curr).css("z-index","20");
        $('.slide' + prev).css("z-index","10");
        $('[class^="slide"]').css("transition","0s");
        $('.slide' + next).css("left","100vw");
        setTimeout(function() {
          $('[class^="slide"]').css("transition","all .5s ease, width 0s, height 0s");
          $('.slide' + next).css("left","0");
          $('.slide' + next).css("transform","scale(1)");
          $('.slide' + prev).css("-moz-transform","scale(1)");
          $('.slide' + next).css("z-index","50");
        },400);
        setTimeout(function() {
          curr++;
          if (curr > count) curr = 1;
          next++;
          if (next > count) next = 1;
          prev++;
          if (prev > count) prev = 1;
        },900);
      } else if (delta > 0) {

        $('.slide' + curr).css("transition","all 0.5s ease, width 0s, height 0s");
        $('.slide' + curr).css("transform","scale(.8)");
        $('.slide' + curr).animate({
            step: function(now,fx) {
              $(this).css('transform',"scale(."+now+")");
            },
            duration:'slow'
        },'linear');
        $('.slide' + curr).css("z-index","20");
        $('.slide' + next).css("z-index","10");
        $('[class^="slide"]').css("transition","0s");
        $('.slide' + prev).css("left","-100vw");
        setTimeout(function() {
          
          $('[class^="slide"]').css("transition","all 0.5s ease, width 0s, height 0s");
          $('.slide' + prev).css("left","0");
          $('.slide' + prev).css("transform","scale(1)");
          $('.slide' + prev).css("-moz-transform","scale(1)");
          $('.slide' + prev).css("z-index","50");
        },400);
        setTimeout(function() {
          curr--;
          if (curr < 1) curr = count;
          next--;
          if (next < 1) next = count;
          prev--;
          if (prev < 1) prev = count;
        },900);
      }

      setTimeout(function() {
        finished = true;
      },1100);
    }
  });
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console