From 02d05a3cb16492d3aee59fd6772fd287794f1a96 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 16 Apr 2013 15:56:22 +0400 Subject: [PATCH] minor edits... Signed-off-by: Alex A. Naanou --- ui/experiments/infinite-ribbon.html | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/experiments/infinite-ribbon.html b/ui/experiments/infinite-ribbon.html index df291540..0f5a88c7 100755 --- a/ui/experiments/infinite-ribbon.html +++ b/ui/experiments/infinite-ribbon.html @@ -13,6 +13,14 @@ function clickHandler(){ +/* Focus next/prev container element +* +* This will shift focus within a container. +* +* If we reach the start/end of the container, we will "warp" around it +* and focus an element from the other end. +* +*/ function shiftSquare(direction, n){ if(n == null){ n = 1 @@ -25,11 +33,10 @@ function shiftSquare(direction, n){ if(n == 0){ return cur } - // see if we need to rotate... + // see if we need to warp arund... if(cur[direction+'All']('.square').length < n){ var sq = cur.closest('.container').children('.square') var i = sq.index(cur) - // rotate... return focus($(sq[ direction == 'next' ? (i + n) % sq.length : sq.length - (Math.abs(i - n) % sq.length) ])) @@ -37,7 +44,7 @@ function shiftSquare(direction, n){ // shift the current element... return focus($(cur[direction+'All']('.square')[n-1])) } -// shift focus left/right... +// shift focus left/right wrappers... function next(n){ return shiftSquare('next', n) }