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 @@

Insertion and removal

- + +