Layered slides implementation using angular slick carousel component

All we need is an easy explanation of the problem, so here it is.

I am using angular-slick (which is based on jquery based slick) to implement carousel control. I have requirement to implement the layerd slides i.e. At a time one slide should display and two slides should be shown half hidden at left and right. On click prev/nex the underneeth slide should come at top and top one should go underneeth.

I was trying to customize it using css/code however not able to figure out how to do. Following is mockups for my requirement. I also checked out the sample given at http://vasyabigi.github.io/angular-slick/
enter image description here

Please advice.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

You should be able to do this via CSS transforms. Basically, scaling down the inactive slides and giving them proper z-indexes results in this effect. For example:

$('.center').slick({
  arrows: true,
  centerMode: true,
  infinite: true,
  centerPadding: '250px',
  slidesToShow: 1,
  speed: 500,
  dots: true,
});
.content {
  width: 800px;
  margin: auto;
  background-color: #EBEBEB;
  height: 480px;
}
.slick-slide:not(.slick-center) {
  z-index: 0;
  transform: scale(0.8);
}
.slick-active.slick-center+.slick-slide+.slick-slide {
  z-index: 1;
}
.slick-active.slick-center+.slick-slide,
.slick-center+.slick-cloned {
  z-index: 2;
}
.slick-center {
  z-index: 3;
}
.slick-slide {
  position: relative;
  transition: transform 80ms;
}
.slide img {
  position: relative;
  transform: translateX(-50%);
  left: 50%;
}
.slick-prev {
  left: 10% !important;
}
.slick-next {
  right: 10% !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http://cdn.jsdelivr.net/jquery.slick/1.5.5/slick.css" rel="nofollow noreferrer noopener" rel="stylesheet" />
<link href="http://cdn.jsdelivr.net/jquery.slick/1.5.5/slick-theme.css" rel="nofollow noreferrer noopener" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/jquery.slick/1.5.5/slick.min.js"></script>

<div class="content">
  <div class="center">
    <div>
      <div class="slide">
        <img src="https://lorempixel.com/540/303/abstract" />
      </div>

    </div>
    <div>
      <div class="slide">
        <img src="https://lorempixel.com/540/303/animals" />
      </div>

    </div>
    <div>
      <div class="slide">
        <img src="https://lorempixel.com/540/303/business" />
      </div>

    </div>
    <div>
      <div class="slide">
        <img src="https://lorempixel.com/540/303/cats" />
      </div>

    </div>
    <div>
      <div class="slide">
        <img src="https://lorempixel.com/540/303/city" />
      </div>

    </div>
    <div>
      <div class="slide">
        <img src="https://lorempixel.com/540/303/food" />
      </div>

    </div>
  </div>
</div>

The example is not using angular-slick, but the principle should be the same.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply