From 27af5a7a26d7b7d5e80b3fdda7adc7b3b5bc6337 Mon Sep 17 00:00:00 2001 From: likelight Date: Sat, 23 Aug 2014 00:10:25 +0800 Subject: [PATCH 1/3] fix bugs fix a bug that when you touch move the swipe the animate will stop and not restart again. Now it can restart. --- swipe.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/swipe.js b/swipe.js index 8b29717..79cac49 100644 --- a/swipe.js +++ b/swipe.js @@ -91,6 +91,7 @@ function Swipe(container, options) { if (options.continuous) slide(index-1); else if (index) slide(index-1); + } function next() { @@ -217,7 +218,11 @@ function Swipe(container, options) { var interval; function begin() { - + // stop the interval if interval still exists + if(interval){ + stop(); + } + delay = options.auto; interval = setTimeout(next, delay); } @@ -312,7 +317,8 @@ function Swipe(container, options) { stop(); // increase resistance if first or last slide - if (options.continuous) { // we don't add resistance at the end + if (options.continuous) { // we don't add res + // istance at the end translate(circle(index-1), delta.x + slidePos[circle(index-1)], 0); translate(index, delta.x + slidePos[index], 0); @@ -334,6 +340,8 @@ function Swipe(container, options) { translate(index, delta.x + slidePos[index], 0); translate(index+1, delta.x + slidePos[index+1], 0); } + //restart the animate + begin(); } @@ -479,6 +487,9 @@ function Swipe(container, options) { slide(to, speed); + //when end the slide ,restart the animate + begin(); + }, prev: function() { @@ -487,6 +498,8 @@ function Swipe(container, options) { prev(); + begin(); + }, next: function() { @@ -495,6 +508,8 @@ function Swipe(container, options) { next(); + begin(); + }, stop: function() { @@ -568,3 +583,5 @@ if ( window.jQuery || window.Zepto ) { } })( window.jQuery || window.Zepto ) } + + From 7f027b1a2dcf80bcb3b0c421f2d311a5825d8f42 Mon Sep 17 00:00:00 2001 From: likelight Date: Sat, 23 Aug 2014 00:24:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整文件格式 --- swipe.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/swipe.js b/swipe.js index 79cac49..d0d2cdc 100644 --- a/swipe.js +++ b/swipe.js @@ -91,7 +91,6 @@ function Swipe(container, options) { if (options.continuous) slide(index-1); else if (index) slide(index-1); - } function next() { @@ -317,8 +316,7 @@ function Swipe(container, options) { stop(); // increase resistance if first or last slide - if (options.continuous) { // we don't add res - // istance at the end + if (options.continuous) { // we don't add res istance at the end translate(circle(index-1), delta.x + slidePos[circle(index-1)], 0); translate(index, delta.x + slidePos[index], 0); @@ -497,7 +495,7 @@ function Swipe(container, options) { stop(); prev(); - + // restart the animate begin(); }, @@ -507,7 +505,7 @@ function Swipe(container, options) { stop(); next(); - + // restart the animate begin(); }, @@ -583,5 +581,3 @@ if ( window.jQuery || window.Zepto ) { } })( window.jQuery || window.Zepto ) } - - From cad478df919406faa0878731ee3598b95b05eebc Mon Sep 17 00:00:00 2001 From: likelight Date: Sat, 23 Aug 2014 00:27:29 +0800 Subject: [PATCH 3/3] 1 format --- swipe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swipe.js b/swipe.js index d0d2cdc..d82af23 100644 --- a/swipe.js +++ b/swipe.js @@ -316,7 +316,7 @@ function Swipe(container, options) { stop(); // increase resistance if first or last slide - if (options.continuous) { // we don't add res istance at the end + if (options.continuous) { // we don't add resistance at the end translate(circle(index-1), delta.x + slidePos[circle(index-1)], 0); translate(index, delta.x + slidePos[index], 0);