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

              
                <!DOCTYPE html>
<html lang="en" dir="ltr">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="HandheldFriendly" content="true">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<title>sLIDER</title>
		<meta name="Description" content="">
	</head>

	<body class="full-screen-for-slider">
		<main>
			<section>
				<div class="container-fluid">
					<div class="row">
						<div class="layout-col layout-col-1 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                <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">
                      <div class="slider-section">
                        <h3>Controls</h3>
                        <p>You can control the slider in 4 ways</p>
                        <a href="#" class="nc btn btn-extra-large"><span class="text">Button</span></a>
                      </div>

                      <div class="slider-section">
                        <p>This slider demo is powered by me along with the Draggable and ThrowProps plugins.</p>
                      </div>

                      <div class="slider-section">
                        <h3>Bottom dot animation</h3>
                        <p>See that animation on the bottom with the navigation dots and rotating slide titles? Its time is based on the position of the draggable element. Keep an eye on it as you drag or the slides animate.</p>
                      </div>

                      <div class="slider-section">
                        <h3>Random dog </h3>
                        <p>Why? Because dogs are cool.</p>
                      </div>

                      <div class="slider-section">
                        <p>Sliders are useful.</p>
                      </div>

                      <div class="slider-section">
                        <h3>Like this demo?</h3>
                        <p>Follow me on Twitter.</p>
                      </div>
                    </div>
                  </div>

                  <div class="dots"></div>

                  <div class="titleWrap">
                    <div class="title">1. Controlling the slider</div>
                    <div class="title">2. Powered by me</div>
                    <div class="title">3. Bottom dot animation</div>
                    <div class="title">4. Random dog</div>
                    <div class="title">5. Sliders are useful</div>
                    <div class="title">6. Follow me on Twitter</div>
                  </div>
                </div>
						</div>
					</div>
				</div>
			</section>
		</main>
	</body>
</html>
              
            
!

CSS

              
                body.full-screen-for-slider {
	height: 100%;
	width: 100%;
	overflow: hidden;
}

.container-fluid {
  padding-left: 0;
  padding-right: 0;
}

.hideMe {
	position: relative;
	opacity: 0;
	height: 100vh;
}

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

#masterWrap #panelWrap {
	height: 100%;
}

#masterWrap #panelWrap .slider-section {
	position: relative;
	height: 100%;
	float: left;

	display: -ms-flexbox;
    display: flex;

    -ms-flex-direction: column;
    flex-direction: column;

    -ms-flex-pack: center;
    justify-content: center;

    -ms-flex-align: center;
    align-items: center;

    /* align-content: center; */
}

.hideMe .dots {
	position: absolute;
	left: 50%;
	bottom: 1.6rem;
	z-index: 100;
}

.hideMe .dot {
	position: relative;
	width: 1.2rem;
	height: 1.2rem;
	border-radius: 50%;
	margin: 1.2rem 0.8rem;
	cursor: pointer;
	float: left;
	background-color: #fff;
}

.hideMe #leftArrow {
	left: 1.2rem;
}

.hideMe #rightArrow {
	right: 1.2rem;
}

.hideMe .arrow {
	position: absolute;
	top: 50%;
	width: 4rem;
	height: 4rem;
	z-index: 100;
	cursor: pointer;
	opacity: 0.75;
	stroke-width: 8px;
	stroke: white;
	fill: transparent;
}

.hideMe .titleWrap {
	position: absolute;
	left: 50%;
	bottom: 5rem;
	height: 3rem;
	z-index: 20;
	overflow-y: hidden;
}

.hideMe .titleWrap .title {
	height: 3rem;
	line-height: 3rem;
	text-align: center;
}
              
            
!

JS

              
                jQuery( document ).ready(function() {
  var colorArray  = ["#683A5E", "#262626", "#426F42", "#8B814C", "#36648B", "#36648B"],
      hideMe      = jQuery(".hideMe"),
      masterWrap  = jQuery("#masterWrap"),
      container   = jQuery("#panelWrap"),
      slides      = container.find(".slider-section"),
      arrow       = hideMe.find(".arrow"),
      leftArrow   = jQuery("#leftArrow"),
      rightArrow  = jQuery("#rightArrow"),
      dur         = 0.5,
      offsets     = [],
      oldSlide    = 0,
      activeSlide = 0,
      dots        = hideMe.find(".dots")[0],
      navDots     = [],
      iw          = jQuery(window).innerWidth(),
      titleWrap   = hideMe.find(".titleWrap"),
      title       = titleWrap.find(".title");

      leftArrow.on("click", function() {
          slideAnim();
      });

      rightArrow.on("click", function() {
          slideAnim();
      });

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

          var newDot = document.createElement("div");
          newDot.className = "dot";
          newDot.index = i;
          navDots.push(newDot);

          jQuery(newDot).on("click", function() {
              slideAnim();
          });

          dots.appendChild(newDot);
      }

      TweenMax.set([dots, titleWrap], {xPercent:-50});
      TweenMax.set(arrow, {yPercent:-50});
      TweenMax.set(title, {y:30});

      var dotAnim = new TimelineMax({paused:true});
      dotAnim.staggerTo(".dot", 1, {scale:2.1,  rotation:0.1, yoyo:true, repeat:1, ease:Linear.easeNone}, 1);
      dotAnim.to(title, slides.length + 1, {y:-(slides.length*30), rotation:0.01, ease:Linear.easeNone}, 0);
      dotAnim.time(1);

      var dragMe = Draggable.create(container, {
          type: "x",
          edgeResistance: 1,
          snap: offsets,
          throwProps:true,
          bounds: "#masterWrap",
          onDrag: tweenDot,
          onThrowUpdate: tweenDot,
          onDragEnd: slideAnim,
          allowNativeTouchScrolling: false,
          zIndexBoost:false
      });

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

      function slideAnim(e) {
          oldSlide = activeSlide;
          // dragging the panels
          if (this.id === "dragger") {
              activeSlide = offsets.indexOf(this.endX);
          } else {
              if (TweenMax.isTweening(container)) {
                  return;
              }
              // arrow clicks
              if (this.id === "leftArrow" || this.id === "rightArrow") {
                  activeSlide = this.id === "rightArrow" ? (activeSlide += 1) : (activeSlide -= 1);
                  // click on a dot
              } else if (this.className === "dot") {
                  activeSlide = this.index;
                  // scrollwheel
              } else {
                  activeSlide = e.deltaY > 0 ? (activeSlide += 1) : (activeSlide -= 1);
              }
          }
          // make sure we're not past the end or beginning slide
          activeSlide = activeSlide < 0 ? 0 : activeSlide;
          if (oldSlide === activeSlide) {
              return;
          }
          // if we're dragging we don't animate the container
          if (this.id != "dragger") {
              TweenMax.to(container, dur, { x: offsets[activeSlide], onUpdate:tweenDot });
          }
      }

      // update the draggable element snap points
      function sizeIt() {
          offsets = [];
          iw = window.innerWidth;

          TweenMax.set("#panelWrap", { width: slides.length * iw });
          TweenMax.set(slides, { width: iw });

          for (let i = 0; i < slides.length; i++) {
              offsets.push(-slides[i].offsetLeft);
          }

          TweenMax.set(container, { x: offsets[activeSlide] });
          dragMe[0].vars.snap = offsets;
      }

      TweenMax.set(hideMe, {opacity:1});

      jQuery(window).on("wheel", function() {
          slideAnim();
      });

      jQuery(window).on("resize", function() {
          sizeIt();
      });

      // update dot animation when dragger moves
      function tweenDot() {
          TweenMax.set(dotAnim, {time:Math.abs(container._gsTransform.x/iw) + 1});
      }
    
});
              
            
!
999px

Console