From 5906421ac7e9fcc57084939e3fc0e2940659dae6 Mon Sep 17 00:00:00 2001 From: Tom Vollerthun Date: Sun, 5 Jul 2015 18:15:27 +0200 Subject: [PATCH] allow to recalculate after new elements have been added to dom --- js/jquery.jTinder.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/js/jquery.jTinder.js b/js/jquery.jTinder.js index 7e72403..7979a97 100644 --- a/js/jquery.jTinder.js +++ b/js/jquery.jTinder.js @@ -19,6 +19,7 @@ dislikeSelector: '.dislike' }; + var tinderslide = null; var container = null; var panes = null; var $that = null; @@ -38,19 +39,26 @@ Plugin.prototype = { - init: function (element) { - container = $(">ul", element); - panes = $(">ul>li", element); - pane_width = container.width(); - pane_count = panes.length; - current_pane = panes.length - 1; - $that = this; + init: function (element) { + $that = this; + tinderslide = element; - $(element).bind('touchstart mousedown', this.handler); - $(element).bind('touchmove mousemove', this.handler); - $(element).bind('touchend mouseup', this.handler); - }, + $that.startOver(); + + $(element).bind('touchstart mousedown', this.handler); + $(element).bind('touchmove mousemove', this.handler); + $(element).bind('touchend mouseup', this.handler); + }, + + startOver: function () { + container = $(">ul", tinderslide); + panes = $(">ul>li", tinderslide); + pane_width = container.width(); + pane_count = panes.length; + current_pane = panes.length - 1; + + }, showPane: function (index) { panes.eq(current_pane).hide();