Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layered slides implementation using angular slick carousel component

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.

like image 802
joy Avatar asked May 07 '15 06:05

joy


1 Answers

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="stylesheet" />
<link href="http://cdn.jsdelivr.net/jquery.slick/1.5.5/slick-theme.css" rel="stylesheet" />
<script src="http://cdn.jsdelivr.net/jquery.slick/1.5.5/slick.min.js"></script>

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

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

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

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

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

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

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

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

like image 102
Yasa Akbulut Avatar answered Nov 13 '22 20:11

Yasa Akbulut