From 61e481b780c1916c5da674879332390b840e9fdf Mon Sep 17 00:00:00 2001 From: Damian Krzeminski Date: Tue, 15 Oct 2013 16:53:09 -0400 Subject: [PATCH] Swipe.loop added to affect how next and prev work If Swipe.loop(true) is called next on the last tile will rewind to the first one, and prev on the first tile will rewind to the last. --- Readme.md | 14 ++++++++++++-- examples/grumpy.html | 1 + index.js | 40 +++++++++++++++++++++++++++++++--------- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/Readme.md b/Readme.md index e3ddc44..1a2dbb2 100644 --- a/Readme.md +++ b/Readme.md @@ -49,6 +49,11 @@ Set the cycle interval, defaults to 5000ms. +### .loop(state) + + Affects the way next/prev are working. + If set to true they rewind after reaching beyond the last (or the first parameter). + ### .refresh() This method should be invoked when the swipe element @@ -72,11 +77,15 @@ ### .prev() - Show the previous item if present, or do nothing. + Show the previous item. + By default, do nothing if showing the first item. + If `loop` is set to true and we are on the first item, display the last item. ### .next() - Show the next item if present, or do nothing. + Show the next item. + By default, do nothing if showing the last item. + If `loop` is set to true and we are on the last item, display the first item. ### .show(i, [ms], [options]) @@ -84,6 +93,7 @@ transition in `ms` defaulting to the `.duration()` value. You may pass `{ silent: true }` as an option to silence show events. + You may pass `{ loop: true }` to treat the position modulo the number of items. ## License diff --git a/examples/grumpy.html b/examples/grumpy.html index b54527c..2850efb 100644 --- a/examples/grumpy.html +++ b/examples/grumpy.html @@ -86,6 +86,7 @@ + loop