From 8b7a9756c673a2900ac83fcd8d186c8b8dcb9747 Mon Sep 17 00:00:00 2001
From: Jason Cheatham
Date: Thu, 30 Nov 2017 16:05:47 -0700
Subject: [PATCH] fix several issues with the Rotator widget
---
widget/Rotator.js | 8 ++++----
widget/tests/test_Rotator.html | 16 +++++++++++++---
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/widget/Rotator.js b/widget/Rotator.js
index b1ee97f231..e9b3dd50b4 100644
--- a/widget/Rotator.js
+++ b/widget/Rotator.js
@@ -185,6 +185,9 @@ define([
}
_t._domNode.removeChild(removed.node);
}
+ if (_t.idx > idx) {
+ _t.idx--;
+ }
}
var index,
@@ -196,7 +199,7 @@ define([
}
else {
for (var i = 0; i < panes.length; i++) {
- if (panes.node === nodeOrIndex) {
+ if (panes[i].node === nodeOrIndex) {
index = i;
break;
}
@@ -220,9 +223,6 @@ define([
}
else {
removeFromPanes(index);
- if (this.idx > index) {
- this.idx--;
- }
}
},
diff --git a/widget/tests/test_Rotator.html b/widget/tests/test_Rotator.html
index a4c90284ca..c778a2f322 100644
--- a/widget/tests/test_Rotator.html
+++ b/widget/tests/test_Rotator.html
@@ -858,8 +858,17 @@
Insertion and removal
myRotator15Inserted = (myRotator15Inserted + 1) % 3
}
- function myRotator15Remove() {
- myRotator15.remove(1);
+ // Remove the first item by index
+ function myRotator15RemoveByIndex() {
+ myRotator15.remove(0);
+ }
+
+ // Remove the first item by node
+ function myRotator15RemoveByNode() {
+ var firstPane = myRotator15.panes[0];
+ if (firstPane) {
+ myRotator15.remove(firstPane.node);
+ }
}
var myRotator15Inserted = 0;
@@ -870,7 +879,8 @@