Skip to content

Commit

Permalink
External functions swipeNext, swipePrev, swipeTo to return true/false.
Browse files Browse the repository at this point in the history
  • Loading branch information
baxang committed Apr 14, 2012
1 parent 5905b0e commit 0e97875
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ var <strong>mySwiper</strong> = new Swiper('.swiper-container')
</code>
<p>Returns the object with couple of useful functions and methods:</p>
<ul>
<li><p><strong>mySwiper.swipeNext()</strong> - run transition to next slide</p></li>
<li><p><strong>mySwiper.swipePrev()</strong> - run transition to previous slide</p></li>
<li><p><strong>mySwiper.swipeNext()</strong> - run transition to next slide. returns true/false.</p></li>
<li><p><strong>mySwiper.swipePrev()</strong> - run transition to previous slide. returns true/false.</p></li>
<li><p><strong>mySwiper.swipeTo(index, speed, runCallbacks)</strong> - run transition to the slide with index number equal to 'index' parameter for the speed equal to 'speed' parameter. You can set 'runCallbacks' to false (by default it is 'true') and transition will not produce onSlideChange(Start/End) callback functions.</p></li>
<li><p><strong>mySwiper.isSupportTouch()</strong> - returns <em>true</em> if browser supports Touch events</p></li>
<li><p><strong>mySwiper.isSupport3D()</strong> - returns <em>true</em> if browser supports CSS3 3D transforms</p></li>
Expand Down
7 changes: 4 additions & 3 deletions idangerous.swiper-1.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ Swiper = function(selector, params, callback) {
if (!_this.positions.current) _this.positions.current = -sliderSize;
//--
var newPosition = Math.ceil(-_this.positions.current/sliderSize)*sliderSize
if (newPosition==wrapperSize) return
if (newPosition==wrapperSize) return false
if (isHorizontal) {
_this.setTransform(-newPosition,0,0)
}
Expand All @@ -389,7 +389,7 @@ Swiper = function(selector, params, callback) {
_this.swipePrev = function() {

var getTranslate = isHorizontal ? _this.getTranslate('x') : _this.getTranslate('y')
if(getTranslate == 0) return
if(getTranslate == 0) return false
var newPosition = (Math.ceil(-_this.positions.current/sliderSize)-1)*sliderSize
/* For external swipePrev Function */
if ( newPosition == - getTranslate ) {
Expand Down Expand Up @@ -436,7 +436,7 @@ Swiper = function(selector, params, callback) {
}

_this.swipeTo = function (index, speed, runCallbacks) {
if (index<0 || index > (numOfSlides-1)) return
if (index<0 || index > (numOfSlides-1)) return false
runCallbacks = runCallbacks===false ? false : runCallbacks || true
var speed = speed===0 ? speed : speed || params.speed
var newPosition = -index*sliderSize ;
Expand All @@ -446,6 +446,7 @@ Swiper = function(selector, params, callback) {
//Run Callbacks
if (runCallbacks)
slideChangeCallbacks()
return true
}

function slideChangeCallbacks() {
Expand Down
Loading

0 comments on commit 0e97875

Please sign in to comment.