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

              
                
<header></header>
<div id="boundary"></div>

<div class="Slate-device">

<div class="Slate-itemsWrapper">

      <section class="Slate-item" data-title="Title 1" data-producer="Producer One" data-country="England">
		  
		  <div class="Slate-itemInner">
              <div class="Slate-mediaWrapper">
                  <div class="Slate-imageWrapper">
                      <img alt="image alt text" src="https://picsum.photos/600/800?random=1"/>
                  </div>
          </div>
        
      </section>

      <section class="Slate-item" data-title="Title 2" data-producer="Producer Two" data-country="Hungry">
  
          <div class="Slate-itemInner">
              <div class="Slate-mediaWrapper">
                  <div class="Slate-imageWrapper">
                      <img alt="image alt text" src="https://picsum.photos/600/800?random=2"/>
                  </div>
              </div>
          </div>
  
      </section>

      <section class="Slate-item" data-title="Title 3" data-producer="Producer Three" data-country="Bulgaria">
  
          <div class="Slate-itemInner">
              <div class="Slate-mediaWrapper">
                  <div class="Slate-imageWrapper">
                      <img alt="image alt text" src="https://picsum.photos/600/800?random=3"/>
                  </div>
              </div>
          </div>
  
      </section>

      <section class="Slate-item" data-title="Title 4" data-producer="Producer Four" data-country="Brazil">
  
          <div class="Slate-itemInner">
              <div class="Slate-mediaWrapper">
                  <div class="Slate-imageWrapper">
                      <img alt="image alt text" src="https://picsum.photos/600/800?random=4"/>
                  </div>
              </div>
          </div>
  
      </section>
  
      <section class="Slate-item" data-title="Title 5" data-producer="Producer Five" data-country="Finland">
  
          <div class="Slate-itemInner">
              <div class="Slate-mediaWrapper">
                  <div class="Slate-imageWrapper">
                      <img alt="image alt text" src="https://picsum.photos/600/800?random=5"/>
                  </div>
              </div>
          </div>
  
      </section>

      <section class="Slate-item" data-title="Title 6" data-producer="Producer Six" data-country="Portugal">
  
          <div class="Slate-itemInner">
              <div class="Slate-mediaWrapper">
                  <div class="Slate-imageWrapper">
                      <img alt="image alt text" src="https://picsum.photos/600/800?random=6"/>
                  </div>
              </div>
          </div>
  
      </section>

      <section class="Slate-item" data-title="Title 7" data-producer="Producer Seven" data-country="France">
  
        <div class="Slate-itemInner">
              <div class="Slate-mediaWrapper">
                  <div class="Slate-imageWrapper">
                      <img alt="image alt text" src="https://picsum.photos/600/800?random=7"/>
                  </div>
              </div>
          </div>

      </section>

      <section class="Slate-item" data-title="Title 8" data-producer="Producer Eight" data-country="Argentina">
  
          <div class="Slate-itemInner">
              <div class="Slate-mediaWrapper">
                  <div class="Slate-imageWrapper">
                      <img alt="image alt text" src="https://picsum.photos/600/800?random=8"/>
                  </div>
              </div>
          </div>
  
      </section>
  
      <section class="Slate-item" data-title="Title 9" data-producer="Producer Nine" data-country="Spain">
  
          <div class="Slate-itemInner">
              <div class="Slate-mediaWrapper">
                  <div class="Slate-imageWrapper">
                      <img alt="image alt text" src="https://picsum.photos/600/800?random=9"/>
                  </div>
              </div>
          </div>
  
      </section>
			
  </div>
	
</div>
	
<footer></footer>
              
            
!

CSS

              
                ::-webkit-scrollbar {
  display: none;
}

/* NEW WAY */
body, html {
  width:100%;
	height:100%;
	overflow:hidden;
	margin:0;
  	display: flex;
  	flex-direction : column;
}
body {
	background-color: #111;
}

header,footer {height:100px;}
#boundary {position:absolute;width:2vw;left:50%;top:0;height:90vh;border:1px solid #ccc;tranlateX(50%);}

.Slate-device {
	 display: flex;
  flex-direction: column;
  align-items: center;
	flex-grow:1;
	width:100%;
}

.Slate-itemsWrapper {
	width:auto;
	display:flex;
	align-items:center;
	justify-content:center;
	flex-direation:rows;
	border:1px solid #666;
	padding-bottom: 50px;
}

.Slate-item {
	width: 8vw;
	height:50vh;
	overflow:hidden;
	margin:0.5vw;
   position: relative;
	z-index:3;
	-webkit-box-reflect: below 10px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(50%, transparent) , to(rgba(250, 250, 250, 0.1)));

}
.Slate-item .Slate-itemInner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: pointer;
}
.Slate-item .Slate-mediaWrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 16vw;
    height: calc(100% + 2px);
    z-index: 0;
}
.Slate-item .Slate-imageWrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
	 background-color: #100a31;
}
.Slate-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
	 min-height: 50vh;
    pointer-events: none;
	filter:grayscale(50%);
}
.Slate-glow {
	box-shadow: 0 0 2px #0ba9ca, 0 0 10px #ef2ba0, 0 0 20px #ff00cc, 0 0 30px #0ba9ca, 0 0 40px #ff00cc, 0 0 50px #ef2ba0; 
}
              
            
!

JS

              
                let expanders = gsap.utils.toArray(".Slate-item");
let wrapper = document.querySelector(".Slate-itemsWrapper");

let active; // keep track of which expander is open

// get center of window 
let window_width = window.innerWidth;
let window_center = window_width/2;

//const i = expanders.length;
let wrapperWidth = wrapper.clientWidth;
let itemWidth = expanders[0].clientWidth;

gsap.set(wrapper,{x:wrapperWidth/2});

expanders.forEach(function(expander, index){

	//create animation for each expander
	let animation = gsap.timeline({paused:true});
	animation.to (expander, {
		width: "16vw", 
		duration:0.4,
		borderColor: "#ff00cc"
	});
	animation.to (expander, {
		duration:0.4,
		borderColor: "#ff00cc"
	});
	//apply the timeline animation to an animation property on the expander
	expander.animation = animation

});

var overlapThreshold = "10%"; 

Draggable.create(".Slate-itemsWrapper", {
	bounds: {minX:-wrapperWidth/2, maxX:wrapperWidth/2},
	type:"x",
	onDrag: updateProgress,
	onDragEnd: dragEnd,
	onDragStart: dragStart
});

function updateProgress() { 
	var i = expanders.length;
     for (var i = 0; i < expanders.length; i++) {
		  console.log(i);
       if (this.hitTest("#boundary", overlapThreshold)) {
         $(expanders[i]).addClass("Slate-glow");
       } else {
         $(expanders[i]).removeClass("Slate-glow");
       }
	  }
}
function dragEnd() {
	// when we end a drag, loop through all 'slate' elements
	for (var i = 0; i < expanders.length; i++) { 
		// if the element has a glow class it must be centered so play animation
		if (expanders[i].classList.contains("Slate-glow")) {
			expanders[i].animation.play();
			break;
		}
	}
}
function dragStart() {
	// when we start a drag, loop through all 'slate' elements
	for (var i = 0; i < expanders.length; i++) { 
		// if the element has a glow class it must be opened so reverse animation
		if (expanders[i].classList.contains("Slate-glow")) {
			expanders[i].animation.reverse();
			break;
		}
	}
}


              
            
!
999px

Console