conveyor-slideshow
Advanced tools
Comparing version 0.7.3 to 0.7.4
{ | ||
"name": "conveyor-slideshow", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"author": "Gil McQuillan, Akhilesh Malla, Peace Chen", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -74,2 +74,3 @@ /* | ||
function createDots(conveyorEl, itemsLength) { | ||
destroyDots(); // re-draw dots in case number of slides has changed | ||
numSlides = itemsLength; | ||
@@ -99,3 +100,3 @@ if (numSlides > 1 && showPaginationDots) { | ||
if (numSlides > 1 && showPaginationDots) { | ||
var dots = containerElement.getElementsByTagName("ol"); | ||
var dots = containerElement.getElementsByClassName("dotsList"); | ||
for (var i = dots.length - 1; i >= 0; i--) { | ||
@@ -108,4 +109,4 @@ dots[i].parentNode.removeChild(dots[i]); | ||
//---------------------------------------------------------------------- | ||
function navigate(direction) { | ||
var items = getItems(); | ||
function navigate(index) { | ||
var items = getItems(); // must retrieve fresh elements list in case DOM has changed | ||
if (items.length < 1) { | ||
@@ -120,3 +121,3 @@ throw {error: "Conveyor: No slides found."}; | ||
// Handle positive & negative wrap-around | ||
currIndex = (currIndex + direction) % items.length; | ||
currIndex = (index) % items.length; | ||
if (currIndex < 0) { | ||
@@ -142,6 +143,4 @@ currIndex = items.length + currIndex; | ||
// Setup previous and next arrow buttons | ||
var prevArrow, | ||
nextArrow; | ||
function createArrows(conveyorEl, numSlides) { | ||
destroyArrows(); // re-draw arrows in case number of slides has changed | ||
if (numSlides < 2) { | ||
@@ -157,4 +156,4 @@ return; // Only show arrows if more than one slide | ||
prevArrow = conveyorEl.getElementsByClassName("conveyor-prev")[0]; | ||
nextArrow = conveyorEl.getElementsByClassName("conveyor-next")[0]; | ||
var prevArrow = conveyorEl.getElementsByClassName("conveyor-prev")[0]; | ||
var nextArrow = conveyorEl.getElementsByClassName("conveyor-next")[0]; | ||
@@ -169,17 +168,23 @@ if (!prevArrow || !nextArrow) { | ||
function destroyArrows() { | ||
prevArrow.removeEventListener("click", prevArrowClickHandler); | ||
var prevArrowParent = prevArrow.parentNode; // aka conveyor-ctrl-left | ||
prevArrowParent.parentNode.removeChild(prevArrowParent); | ||
nextArrow.removeEventListener("click", nextArrowClickHandler); | ||
var nextArrowParent = nextArrow.parentNode; // aka conveyor-ctrl-right | ||
nextArrowParent.parentNode.removeChild(nextArrowParent); | ||
// must retrieve fresh elements in case DOM has changed | ||
var prevArrow = conveyor.getElementsByClassName("conveyor-prev")[0]; | ||
if(prevArrow) { | ||
prevArrow.removeEventListener("click", prevArrowClickHandler); | ||
var prevArrowParent = prevArrow.parentNode; // aka conveyor-ctrl-left | ||
prevArrowParent.parentNode.removeChild(prevArrowParent); | ||
} | ||
var nextArrow = conveyor.getElementsByClassName("conveyor-next")[0]; | ||
if(nextArrow) { | ||
nextArrow.removeEventListener("click", nextArrowClickHandler); | ||
var nextArrowParent = nextArrow.parentNode; // aka conveyor-ctrl-right | ||
nextArrowParent.parentNode.removeChild(nextArrowParent); | ||
} | ||
} | ||
function prevArrowClickHandler(ev) { | ||
navigate(-1); | ||
navigate(currIndex-1); | ||
} | ||
function nextArrowClickHandler(ev) { | ||
navigate(1); | ||
navigate(currIndex+1); | ||
} | ||
@@ -186,0 +191,0 @@ //---------------------------------------------------------------------- |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16199
314