@rberthome wrote:
Hello,
I'm looking for a way to not have bounce at the beginning and the end of the swiper.
I make a solution which lock and unlock to prev and next by looking at the position of the currently slide shown and by working with the progress when a user is swiping.
This is what I have done :
Controller :
var onInitEnded = function(mySwiper){ $scope.mySwiper = mySwiper; }; var lockIfStartOrEnd = function(mySwiper){ if(mySwiper.isBeginning && mySwiper.progress <= 0) { mySwiper.lockSwipeToPrev(); } else { mySwiper.unlockSwipeToPrev(); } if(mySwiper.isEnd && mySwiper.progress >= 1) { mySwiper.lockSwipeToNext(); } else { mySwiper.unlockSwipeToNext(); } }; var onSlideChangeEnd = function(mySwiper){ lockIfStartOrEnd(mySwiper); } var onProgress = function(mySwiper){ //unlock swipe in order to swipe back if the previous article is not totally selected. // if the actual position is more than the position of the article's center. => go back. if(mySwiper.isEnd) { if (mySwiper.progress < 1 && (1/$scope.cardsToRead.length) * mySwiper.activeIndex < mySwiper.progress) { mySwiper.unlockSwipeToNext(); } $timeout(function(){ mySwiper.lockSwipeToNext(); }, 400); } else { mySwiper.unlockSwipeToNext(); } if(mySwiper.isBeginning) { if (mySwiper.progress > 0 && (1/$scope.cardsToRead.length) > mySwiper.progress) { mySwiper.unlockSwipeToPrev(); } $timeout(function(){ mySwiper.lockSwipeToPrev(); }, 400); } else { mySwiper.unlockSwipeToPrev(); } } //Options of the swiper $scope.mySliderOptions = { observer : true, pagination:'', onInit : onInitEnded, onSlideChangeEnd : onSlideChangeEnd, onProgress : onProgress };
HTML :
<ion-slides options="mySliderOptions" style="height:100%" slider="mySwiper"> <ion-slide-page class="slide" ng-repeat="card in cardsToRead">
I tried to set the freeModeMomentumBounce to false in the options but it didn't work.
Does the swiper have any options to not have the bounce effect ?
Thanks.
Posts: 1
Participants: 1