From 4180cdf2d462664df1b90ffa0988d0034bbe2437 Mon Sep 17 00:00:00 2001 From: Anders Nysom Date: Fri, 12 Feb 2016 21:57:21 +0100 Subject: [PATCH] added slide to column functionality --- www/js/GridColumnCarousel.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/www/js/GridColumnCarousel.js b/www/js/GridColumnCarousel.js index 24a52e0..a84e2fc 100644 --- a/www/js/GridColumnCarousel.js +++ b/www/js/GridColumnCarousel.js @@ -202,6 +202,14 @@ } } + //will slide to the page that currently displays the element indicated by the index + function slideToElementIndex(index) { + //find out which page the element is presented on. + var itemsPrSlide = slideWidth / colItemWidth; + var pageIndex = Math.floor(index / itemsPrSlide); + slideToPage(pageIndex); + } + function onIndicatorClick(e) { slideToPage(getIndex(e.currentTarget)); } @@ -213,7 +221,7 @@ this.slide = function(page) { //if argument is number, call slideToPage directly if(typeof page === 'number') { - slideToPage(page); + slideToElementIndex(page); return; } @@ -261,7 +269,7 @@ //This will reinstantiate the entire carousel. Remove old state and find //list items and calculating item sizes. - this.reinitialize = reinitialize; + this.reinstantiate = reinstantiate; } w.GCCarousel = GCCarousel;