I am using bxSlider to display a card carousel. My settings -
var carousel = {
minSlides: 4.5,
maxSlides: 4.5,
slideWidth: 250,
pager: false,
moveSlides: 4,
speed:2000,
hideControlOnEnd:true
}
Is there a way that on clicking 'next' I could display the first card as half, too?(without changing the width of the slider)
I am trying to change the value along x-axis as below but the slider stops working.
.slider{
transform: translate3d(-900px, 0px, 0px) !important;
}
How can I achieve this?
EDIT: A simpler and direct approach to this was provided by 'Karan' and works perfectly. However, I want that this effect should apply only after the user clicks 'next' and not at first display of cards.
My code below -
function translate(){
var current = carousel.getCurrentSlide();
if(current>=1){
$('div.slider')
.css({'margin-left': '5.56%','margin-right': '5.56%' } );
}
}
Calling this function on clicking next as-
onSlideAfter: function() {
translate();
This works fine except that when I click previous and go back to the initial display, it again shows as half.
What am I missing here?
You can add below css to your code. As you are displaying
4.5slides each slide will get22.22%width from div. And you want to displayhalffromfirstandlastslides so you will need to0.25%widthfromfirstandlastslides. So you can divide22.22/4and setmargin-leftandmargin-right.Try it below.