From c7849b62d7e1e53598b3145d175ce9afbe753112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Saive?= Date: Mon, 23 Nov 2015 23:04:21 +0100 Subject: [PATCH 1/3] implement onBeforeNext and onAfterNext in addition to onFinish --- js/jquery.jTinder.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/jquery.jTinder.js b/js/jquery.jTinder.js index 7e72403..be1fbc0 100644 --- a/js/jquery.jTinder.js +++ b/js/jquery.jTinder.js @@ -58,7 +58,16 @@ }, next: function () { - return this.showPane(current_pane - 1); + $that.settings.onBeforeNext + && $that.settings.onBeforeNext(current_pane); + + //@link https://github.com/Stemlet/jTinder/commit/f3565b6f2376ebaf013306829b2b3fcfa5f4c938 + !current_pane && $that.settings.onFinish && $that.settings.onFinish(); + var showResult = this.showPane(current_pane - 1); + + $that.settings.onAfterNext + && $that.settings.onAfterNext(current_pane); + return showResult; }, dislike: function() { From 79c4b8cf3b412f10187e26aa2aee8d281d912082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Saive?= Date: Mon, 23 Nov 2015 23:07:44 +0100 Subject: [PATCH 2/3] add documentation for integrated PR and added source code. --- js/jquery.jTinder.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/jquery.jTinder.js b/js/jquery.jTinder.js index be1fbc0..fa86128 100644 --- a/js/jquery.jTinder.js +++ b/js/jquery.jTinder.js @@ -58,13 +58,18 @@ }, next: function () { + // Call to onBeforeNext if available, passing the current + // index as an argument $that.settings.onBeforeNext && $that.settings.onBeforeNext(current_pane); //@link https://github.com/Stemlet/jTinder/commit/f3565b6f2376ebaf013306829b2b3fcfa5f4c938 + // Call to onFinish if available, no arguments passed !current_pane && $that.settings.onFinish && $that.settings.onFinish(); var showResult = this.showPane(current_pane - 1); + // Call to onAfterNext if available, passing the current + // index as an argument $that.settings.onAfterNext && $that.settings.onAfterNext(current_pane); return showResult; From 225e0ffc54752ac8f715b366279e5a0783cbf703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Saive?= Date: Wed, 2 Dec 2015 07:30:49 +0100 Subject: [PATCH 3/3] PR#7: add jTinder.rewind() function for looping feature. --- js/jquery.jTinder.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/js/jquery.jTinder.js b/js/jquery.jTinder.js index fa86128..9e7d3d5 100644 --- a/js/jquery.jTinder.js +++ b/js/jquery.jTinder.js @@ -64,8 +64,9 @@ && $that.settings.onBeforeNext(current_pane); //@link https://github.com/Stemlet/jTinder/commit/f3565b6f2376ebaf013306829b2b3fcfa5f4c938 - // Call to onFinish if available, no arguments passed - !current_pane && $that.settings.onFinish && $that.settings.onFinish(); + // PR#1: Call to onFinish if available, no arguments passed + // PR#7: Add passing "this" to be able to call rewind on the instance. + !current_pane && $that.settings.onFinish && $that.settings.onFinish(this); var showResult = this.showPane(current_pane - 1); // Call to onAfterNext if available, passing the current @@ -75,6 +76,23 @@ return showResult; }, + /** + * jTinder.rewind() function for looping feature. + * The rewind method removes the CSS transformations from the panels + * and shows them again. Additionally it rewinds the current_pane + * index of the jTinder instance. + * @author: Grégory Saive (http://github.com/evias) + **/ + rewind: function() { + $.each(panes, function(index, panel) + { + var jqElm = $(panel); + jqElm.css("transform", ""); + jqElm.show(); + current_pane = index+1; + }); + }, + dislike: function() { panes.eq(current_pane).animate({"transform": "translate(-" + (pane_width) + "px," + (pane_width*-1.5) + "px) rotate(-60deg)"}, $that.settings.animationSpeed, function () { if($that.settings.onDislike) {