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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                .video-bg
  .text-content
    .par That's it folks, thanks for coming!<br>Follow me for more awesome interaction like this in the future.
    button.close Go back

.translucent-ctr
  .translucent

.slider-ctr
  .text-content
    .title Select Movies
    .par.detail Scroll horizontally to navigate

  .slider-scroll
  
    - var moviesClass = ["deadpool", "godfather", "goodbadugly", "darkknight", "godfather2", "twelveangrymen", "django", "wallflower", "shawshank"]
    - var moviesName = ["Deadpool", "The Godfather", "The Good, Bad, and Ugly", "The Dark Knight", "The Godfather 2", "12 Angry Men", "Django Unchained", "The Perks of being Wallflower", "Shawshank Redemption"]
    
    - for(var i = 0; i < 9; i++) {
    
      .slide
        figure
          .image-ctr
            .image("class" = moviesClass[i], "data-index" = "{#i}")
              .light
            figcaption #{moviesName[i]}
            
    - }

              
            
!

CSS

              
                @import "bourbon";

$shadow: 0 4px 20px 2px rgba(0, 0, 0, 0.25);

@font-face {
  font-family: "San Francisco";
  font-weight: 400;
  src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-regular-webfont.woff");
}

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

html,
body {
  position: relative;
  height: 100%;
}

body {
  font-family: "San Francisco";
  @include transform-style(preserve-3d);
  @include transform(perspective(1600px));
  overflow: hidden;
}

.video-bg {
  @include position(absolute, 0 0 0 0);
  width: 100%;
  height: 100%;
  z-index: 10;
  display: table;
  pointer-events: none;
  opacity: 0;
  transition: .3s all ease;
  background: rgba(0,0,0,.6);
  @include transform(scale(1.1));
  
  &.active {
    opacity: 1;
    @include transform(scale(1));
    pointer-events: auto;
  }
  
  .text-content {
    display: table-cell;
    vertical-align: middle;
    text-align: center;
  }
  
  .par {
    color: #fff;
    line-height: 1.5;
    margin-bottom: 40px;
    font-size: 20px;
    opacity: .8;
  }
  
  button {
    padding: 15px 40px;
    border: none;
    font-size: 16px;
    background: #fff;
    color: #000;
    border-radius: 3px;
    cursor: pointer;
    box-shadow: 0 4px 20px 2px rgba(0, 0, 0, 0.25);
    transition: .2s all cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: transform;
    
    &:hover {
      @include transform(scale(1.1));
    }
    
    &:active {
      @include transform(scale(1));
    }
    
    &:focus {
      outline: none;
    }
  }
}

.translucent-ctr {
  @include position(absolute, 0 0 0 0);
  z-index: 9;
  filter: blur(30px);
  -webkit-filter: blur(30px);
  background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/yosemite.jpg") no-repeat center center/cover;
  @include transform(scale(1.2));
    
  .translucent {
    @include position(absolute, 0 0 0 0);
    background: #f5f5f5;
    opacity: .5;
  }
}


.slider-ctr {
  overflow: scroll;
  @include position(fixed, 0 0 0 0);
  scroll-snap-type: proximity;
  scroll-snap-destination: 30px 0;
  z-index: 9;
  
  &.disabled {
    pointer-events: none;
  }
  
  .text-content {
    position: fixed;
    top: 60px;
    left: 60px;
  }
  
  .title {
    font-size: 30px;
    margin-bottom: 10px;
    color: #555;
  }
  
  .par {
    color: #777;
  }
}

.slider-scroll {
  @include position(absolute, 0 0 0 0);
  width: 3060px;
  padding: 0 30px;
  box-sizing: content-box;
  
  .slide {
    width: 340px;
    height: 100%;
    float: left;
    box-sizing: border-box;
    padding: 0 30px;
    display: table;
    scroll-snap-coordinate: 0 0;
  }
  
  figure {
    display: table-cell;
    vertical-align: middle;
    width: 100%;
  }
  
  .image-ctr {
    width: 100%;
    position: relative;
    transition: .2s all cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    will-change: transform;
    
    &.disabled {
      pointer-events: none;
      transition: none;
    }
    
    &:hover {
      @include transform(scale(1.2));
    }
    
    figcaption {
      @include position(absolute, x 0 -40px 0);
      font-size: 16px;
      line-height: 40px;
      text-align: center;
      color: #fff;
      letter-spacing: 1px;
      opacity: 0;
      transition: .15s opacity ease;
    }
    
    &:hover figcaption {
      opacity: 1;
      transition: .15s opacity ease .1s;
    }
  }
  
  .image {
    box-shadow: $shadow;
    border-radius: 3px;
    width: 100%;
    height: 417px;
    position: relative;
    background: no-repeat center center / cover;
    
    .light {
      @include position(absolute, 0 0 0 0);
      z-index: 9;
      opacity: 0;
      transition: .15s opacity ease;
      border-radius: 3px;
      
      &.light-on {
        opacity: 1;
      }
    }
    
    &:before {
      content: "";
      @include position(absolute, 0 0 0 0);
      box-shadow: 0 30px 30px rgba(0, 0, 0, 0.5);
      transition: .15s all ease-out;
      opacity: 0;
      border-radius: 5px;
    }
    
    &:hover:before {
      opacity: 1;
    }
    
    &.shawshank {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/shawshank.jpg");
    }
    
    &.godfather {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/godfather.jpg");
    }
     
    &.godfather2 {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/godfather2.jpg");
    }
    
    &.darkknight {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/darkknight_copy.jpg");
    }
    
    &.twelveangrymen {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/twelveangrymen.jpg");
    }
    
    &.django {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/django.jpg");
    }
    
    &.goodbadugly {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/goodbadugly.jpg");
    }
    
    &.deadpool {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/deadpool.jpg");
    }
    
    &.wallflower {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/wallflower.jpg");
    }
    
  }
}

.copyright {
  z-index: 99;
}
              
            
!

JS

              
                function $(elem){
  return document.querySelector(elem);
}

function $$(elem){
  return document.querySelectorAll(elem);
}

// beep
var audio = new Audio("https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/beep3.wav");

var imagesCtr = $$(".image-ctr"),
    images = $$(".image"),
    imagesLength = images.length - 1;

// nodelist to array
imagesCtr = [].slice.call(imagesCtr);

var sliderCtr = $(".slider-ctr"),
    videoBg = $(".video-bg"),
    title = $(".title"),
    detail = $(".detail");

// get the next siblings of selected element
function nextSiblings(x, y){
  var arr = [];
  for(y; y < x; x--){
    arr.push(x);
  }
  return arr.reverse();
}

// get the previous siblings of selected element
function prevSiblings(x){
  var arr = [];
  for(var y = -1, x = x - 1; y < x; x--){
    arr.push(x);
  }
  return arr;
}

var tl = new TimelineMax(),
    tlText = new TimelineMax(),
    tlAdditional = new TimelineMax();

images.forEach(function(image){
  
  image.addEventListener("click", function(){
      
    setTimeout(function(){
      videoBg.classList.add("active");
    }, 600);
    
    var index = parseInt(this.getAttribute("data-index")),
        yAnim = -40,
        thisImage = this;
    
    console.log(this)
    
    tlText
      .staggerTo([title, detail], .15, {
        y: -15,
        opacity: 0
      }, -.15)
      .set([title, detail], {
        y: 15
      })
    
    tl
      .set(thisImage, {
      className: "+=selected disabled"
    })
      .to(thisImage, .05, {
      scale: 1,
      easing: Elastic.easeOut
    })
      .to(thisImage, .15, {
      opacity: 0,
      y: yAnim,
      onComplete: nextTl
    })
      .set(thisImage, {
      y: yAnim * (-1),
    })
    
    prevSiblings(index).map(function(x){
      tl.set(imagesCtr[x], {
        className: "+=disabled"
      }).to(imagesCtr[x], .15, {
        opacity: 0,
        y: yAnim
      }).set(imagesCtr[x], {
        y: yAnim * (-1),
      })
    });
    
    function nextTl() {
      nextSiblings(imagesLength, index).map(function(x){
        tlAdditional.set(imagesCtr[x], {
          className: "+=disabled"
        }).to(imagesCtr[x], .15, {
          opacity: 0,
          y: yAnim
        }).set(imagesCtr[x], {
        y: yAnim * (-1),
      })
      })
    }
    
  });
  
  image.addEventListener("mouseenter", function(){
    this.children[0].classList.add("light-on");
  });
  
  image.addEventListener("mousemove", function(e){
    var w = this.offsetWidth,
        h = this.offsetHeight,
        o = 9 - e.offsetX / w * 18,
        a = 9 - e.offsetY / h * 18,
        n = e.offsetX - w / 2,
        r = e.offsetY - h / 2,
        s = Math.atan2(r, n),
        t = 180 * s / Math.PI - 90,
        transform = "translateY(" + -o + "px) translateX(" + -a + "px) rotateX(" + -a + "deg) rotateY(" + -o + "deg)";
    
    this.style.MozTransform = transform;
    this.style.WebkitTransform = transform;
    
    this.children[0].style.background = "linear-gradient(" + t + "deg, rgba(255,255,255," + e.offsetY / h / 2 + ") 0%,rgba(255,255,255,0) 60%)";
    
  });
  
  image.addEventListener("mouseleave", function(e){
    this.style.MozTransform = "none";
    this.style.WebkitTransform = "none";
    this.children[0].classList.remove("light-on");
  });
  
});

var closeBtn = $(".close");

closeBtn.addEventListener("mouseenter", function(){
  audio.play();
});

closeBtn.addEventListener("click", function(){
  videoBg.classList.remove("active");
  
  var imageSelected;
  
  imagesCtr.filter(function(x){
    if(x.classList.contains("selected")){
      return imageSelected = x;
    }
  });
  
  var index = parseInt(imageSelected.children[0].getAttribute("data-index"));
  
  tlText.staggerTo([title, detail], .15, {
    y: 0,
    opacity: 1
  }, .15)
  
  tl
    .to(imageSelected, .15, {
    delay: .15,
    opacity: 1,
    y: 0,
    onComplete: nextTl
  })
    .set(imageSelected, {
    className: "-=selected disabled",
    attr: {"style": "none"}
  })
  
  prevSiblings(index).map(function(x){
    tl
      .to(imagesCtr[x], .15, {
      opacity: 1,
      y: 0,
      delay:  -.05
    })
      .set(imagesCtr[x], {
      className: "-=disabled",
      attr: {"style": "none"}
    })
    
  });

  function nextTl() {
    nextSiblings(imagesLength, index).map(function(x){
      tlAdditional
        .to(imagesCtr[x], .15, {
        opacity: 1,
        y: 0,
        delay:  -.05
      })
        .set(imagesCtr[x], {
        className: "-=disabled",
        attr: {"style": "none"}
      })
    })
  }
  
});

balapaCop("Apple TV Interaction", "rgba(255,255,255,.8)");
              
            
!
999px

Console