Swiper: How to make "mySwiper.swipePrev()" & "mySwiper.swipeNext()" to goto slide which is not visible?

Created on 15 Jul 2014  路  3Comments  路  Source: nolimits4web/swiper

I have a problem,

Kindly look here for my codes:

https://github.com/sackIndian/swiper-problem3

(set your browser width to: 900px or less)

For the first swiper:
if i press on next button it should pull all "swiper-slide-visible" slides and stop at next slide which does not have "swiper-slide-visible" class?

How can i implement this? Any idea.

At second swiper:
I have added all my contents inside a single slide to achieve this, but how can i make "swiper-slide" to set(get content width) according to its content width?

Confused iff have any direct solution?

All 3 comments

For the first swiper:

$('.next').click(function(){
  var index = $('.swiper-container .swiper-slide-visible').eq(0).index();
  mySwiper.swipeTo(index);
})

For second swiper just set its wrapper default width high as possibe:

.swiper-container2 .swiper-wrapper {
  width:20000px;
}

Hi @nolimits4web , thanks for the idea.

For the first swiper:
I think we need to make few changes to your code to make it work perfectly:

For next click,

var lengthOf = $('.swiper-container .swiper-slide-visible').length;
var index = $('.swiper-container .swiper-slide-visible').eq(lengthOf-1).index(); 
mySwiper.swipeTo(index+1);

And for prev click,

var xWrapperTrans = (mySwiper.getWrapperTranslate("x"))
var widthOfContainer = $(".swiper-container > .swiper-wrapper").css("width").slice(0, -2);
var visibleAreaWidth = ($(".swiper-container").width()); //total area
var xposition = ((xWrapperTrans+visibleAreaWidth)<=0)?(xWrapperTrans+visibleAreaWidth):0;

mySwiper.setWrapperTranslate(xposition,0,0);

Will there be any improved solution you would like to mention.

.swiper-container2 .swiper-wrapper {
width:20000px;
}

is solved my second problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

QJan84 picture QJan84  路  3Comments

durchanek picture durchanek  路  4Comments

magic-77 picture magic-77  路  3Comments

lxmarinkovic picture lxmarinkovic  路  4Comments

voodoo6 picture voodoo6  路  3Comments