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

              
                <div class="c-exp-gallery__slider js-experience-slider">
		<div class="c-exp-gallery__inner js-experience-slider__inner">
			<div class="c-exp-gallery__content js-experience-slider__content">

				<div class="c-exp-gallery-slide js-experience-slide">
					<div class="c-exp-gallery-slide__proxy"></div>
					<figure class="c-exp-gallery-slide__img">
						<img src="https://images.unsplash.com/photo-1526973578717-38e3919604e8?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=c737c70c1dc740c8285f0074eaaab520" alt="">
					</figure>
				</div>

				<div class="c-exp-gallery-slide js-experience-slide">
					<div class="c-exp-gallery-slide__proxy"></div>
					<figure class="c-exp-gallery-slide__img">
						<img src="https://images.unsplash.com/photo-1526973578717-38e3919604e8?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=c737c70c1dc740c8285f0074eaaab520" alt="">
					</figure>
				</div>

				<div class="c-exp-gallery-slide js-experience-slide">
					<div class="c-exp-gallery-slide__proxy"></div>
					<figure class="c-exp-gallery-slide__img">
						<img src="https://images.unsplash.com/photo-1526973578717-38e3919604e8?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=c737c70c1dc740c8285f0074eaaab520" alt="">
					</figure>
				</div>

        				<div class="c-exp-gallery-slide js-experience-slide">
					<div class="c-exp-gallery-slide__proxy"></div>
					<figure class="c-exp-gallery-slide__img">
						<img src="https://images.unsplash.com/photo-1526973578717-38e3919604e8?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=c737c70c1dc740c8285f0074eaaab520" alt="">
					</figure>
				</div>
        
        				<div class="c-exp-gallery-slide js-experience-slide">
					<div class="c-exp-gallery-slide__proxy"></div>
					<figure class="c-exp-gallery-slide__img">
						<img src="https://images.unsplash.com/photo-1526973578717-38e3919604e8?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=c737c70c1dc740c8285f0074eaaab520" alt="">
					</figure>
				</div>
        
        				<div class="c-exp-gallery-slide js-experience-slide">
					<div class="c-exp-gallery-slide__proxy"></div>
					<figure class="c-exp-gallery-slide__img">
						<img src="https://images.unsplash.com/photo-1526973578717-38e3919604e8?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=c737c70c1dc740c8285f0074eaaab520" alt="">
					</figure>
				</div>
        
        				<div class="c-exp-gallery-slide js-experience-slide">
					<div class="c-exp-gallery-slide__proxy"></div>
					<figure class="c-exp-gallery-slide__img">
						<img src="https://images.unsplash.com/photo-1526973578717-38e3919604e8?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=c737c70c1dc740c8285f0074eaaab520" alt="">
					</figure>
				</div>
        
			</div>
		</div>
  <div class="proxy"></div>
	</div>
              
            
!

CSS

              
                @function size-calc($base) {
	$value: calc(#{$base} * (100vw / 1440));
	@return $value;
}

.c-exp-gallery__slider {
  position: relative;
}

.proxy {
  position: absolute;
  top:0;
  left:0;
  height: 100%;
  width: 100%;
}

html, body{
  height: 100%;
}

body{
  display: flex;
  align-items: center;
  overflow: hidden;
}

img{
  display: block;
  width: 100%;
  height: auto;
}

.c-exp-gallery{
	padding-bottom: size-calc(500);

	&__slider{
		width: 100vw;
	}

	&__inner{
		white-space: nowrap;
	}

	&-slide{
		display: inline-block;
		position: relative;
		padding: 0 size-calc(60);

		&__img{
			width: 50vw;
		}

		&__content{
			display: none;
			position: absolute;
			top: 100%;
			left: 0;
			right: 0;
			padding-top: size-calc(35);
		}
	}
}
              
            
!

JS

              
                class DraggableSlider {

	constructor() {
		this.container = document.querySelector('.js-experience-slider');
    this.proxy = this.container.querySelector(".proxy");
		this.slider = document.querySelector('.js-experience-slider__inner');
		this.sliderContent = document.querySelector('.js-experience-slider__content');
		this.slides = [...this.container.querySelectorAll('.js-experience-slide')];
		this.slidesNumb = this.slides.length;
		this.sliderWidth = 0;

		this.draggable = null;

		this.current = 0;
		this.last = 0;

		this.init();
	}

	setBounds() {
		this.sliderWidth = this.slides[0].offsetWidth * this.slidesNumb;

		TweenMax.set([this.slider, this.proxy], {
			width: this.sliderWidth, x:"+=0", skewType:"simple"
		});
	}

	createDraggable() {
    var slider = this.slider,
        tracker = ThrowPropsPlugin.track(slider, "x"),
        pressedTop; //when the users presses down, if the mouse is in the top half of the image, pressedTop will be true. We use this to make the skewing more natural, like the mouse is "pulling" that part of the image
		this.draggable = Draggable.create(this.proxy, {
		    type: "x",
		    edgeResistance: 0.75,
        onPress: function(e) {
          var bounds = this.target.getBoundingClientRect();
          pressedTop = (e.clientY < bounds.y + bounds.height / 2);
          //keep track of how far apart the proxy is from the slider because when the user presses down, we want to IMMEDIATELY stop any motion, thus this offset value becomes baked in until release.
          this.offset = this.x - slider._gsTransform.x;
          TweenLite.killTweensOf(slider); //in case it's moving
          TweenLite.to(slider, 0.2, {skewX:0});
        },
        onDrag: function() {
          TweenLite.to(slider, 0.8, {
            x:this.x - this.offset, 
            skewX:"+=1", //meaningless - we tweak the values in the modifier below. We needed to make the skewX tween to something just so that it's included in the tweening values.
            modifiers:{
              //skew based on the current velocity, capped at 20 in either direction
              skewX:function(v) {
                var skew = tracker.getVelocity("x") / 200;
                if (skew > 20) {
                  skew = 20;
                } else if (skew < -20) {
                  skew = -20;
                }
                return pressedTop ? -skew : skew;
              }
            }, 
            ease:Power2.easeOut
          });
        },
        onRelease: function() {
          //if the user just presses down and releases without really moving much at all, there's no need to do a throwProps tween.
          if (this.tween && Math.abs(tracker.getVelocity("x")) > 20) {
            TweenLite.to(slider, this.tween.duration(), {throwProps:{x:{end:this.endX}}, ease:Power3.easeOut});
          }
          TweenLite.to(slider, 0.5, {skewX:0, ease:Power1.easeOut})
        },
		    //dragResistance: 0.5,
		    bounds: this.container,
		    throwProps: true
		})[0];
	}

	destroy() {
		this.draggable.kill()
	}

	init() {
		this.setBounds()
		this.createDraggable()
	}
}

const slider = new DraggableSlider()
              
            
!
999px

Console