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.

            
              <div class="container">
  <div class="Wallop gallery" id="gallery">
    <!-- Left Preview Tile  -->
    <div class="Wallop-buttonPrevious gallery__aside">
      <div class="gallery__column">
        <div class="gallery__item" id="leftPreview"></div>
      </div>
    </div>
    <!-- Right Preview Tile  -->
    <div class="Wallop-buttonNext gallery__aside gallery__aside--right">
      <div class="gallery__column">
        <div class="gallery__item" id="rightPreview"></div>
      </div>
    </div>

    <!-- Image Box  -->
    <!-- Include all images here  -->
    <!-- More on the image slider - http://pedroduarte.me/wallop/ -->
    <div class="gallery__column Wallop-list" id="galleryBox">
      <div class="gallery__item Wallop-item" style="background: url('https://static.pexels.com/photos/33109/fall-autumn-red-season.jpg'); background-size: cover;"></div>
      <div class="gallery__item Wallop-item" style="background: url('https://static.pexels.com/photos/39811/pexels-photo-39811.jpeg'); background-size: cover;"></div>
      <div class="gallery__item Wallop-item" style="background: url('https://static.pexels.com/photos/230629/pexels-photo-230629.jpeg'); background-size: cover;"></div>
      <div class="gallery__item Wallop-item" style="background: url('https://static.pexels.com/photos/34950/pexels-photo.jpg'); background-size: cover;"></div>
    </div>
  </div>
</div>


            
          
!
            
              .gallery {
  /*  Let the gallery fill the container */
  height: 100%;
  width: 100%;
  display: flex;
  /* On click fadeOut to black rather than white  */
  background-color: black;
}

.gallery__aside {
  display: flex;
  /*  Fill the available space, */
  /*  but no more than 10% of screen width  */
  flex: 1;
  max-width: 10%;
  
  /*  Styling and transition of side boxes  */
  filter: brightness(.6) saturate(.15);
  transition: filter 0.2s ease-out;
}

.gallery__aside:hover {
  filter: brightness(1) saturate(.6);
  cursor: pointer;
}

/* Move second preview box to the right */
.gallery__aside--right {
  order: 3;
}

/* Make each column flexible (especially vertically) */
.gallery__column {
  flex: 1;
}

.gallery__item {
  /*  Fill the available space (that is 100vh)  */
  height: 100%;
 }

/* Container for the gallery */
/* Could just as well be the whole page */
.container {
  width: 99vw;
  height: 96vh;
}

            
          
!
            
              // Initialize wallop.js image slider
var wallopEl = document.querySelector('.Wallop');
var slider = new Wallop(wallopEl);

// Find preview tiles and main image box
var leftPreview = document.getElementById("leftPreview");
var rightPreview = document.getElementById("rightPreview");
var gallery = document.getElementById("galleryBox");

// Listen for image change on preview tiles click
slider.on('change', onSliderChange);

function onSliderChange(event) {
  // Manually determine index of next and previous picture
  var allImagesArray = slider.allItemsArray;
  var lastImageIndex = slider.allItemsArray.length - 1;
  var previousImageIndex = slider.currentItemIndex - 1 < 0 ? lastImageIndex : slider.currentItemIndex - 1;
  var nextImageIndex = slider.currentItemIndex + 1 > lastImageIndex ? 0 : slider.currentItemIndex + 1;

  // Get the background image property declared within html
  var previousImage = allImagesArray[previousImageIndex].getAttribute("style");
  var nextImage = allImagesArray[nextImageIndex].getAttribute("style");

  // Pass the background image of next and previous image to animate function
  fadeOutIn(leftPreview, previousImage);
  fadeOutIn(rightPreview, nextImage);

}

function fadeOutIn(element, background) {
  // Prepare GSAP TimeLine variable
  var timeline = new TimelineLite();
  
  // First, fade out the current picture
  timeline.to(element, 0.2, {
    opacity: 0.2,
    display: "none",
    // Once the fade out is complete, change background image of both tile boxes
    onComplete: function () {
      element.setAttribute("style", background);
    }

  });

  // Then fade in again
  timeline.to(element, 0.1, {
    opacity: 1,
    display: "block"
  });
}


            
          
!
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