Skip to content

Commit

Permalink
fix several issues with the Rotator widget
Browse files Browse the repository at this point in the history
  • Loading branch information
jason0x43 authored and dylans committed Nov 30, 2017
1 parent 51509f9 commit 8b7a975
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
8 changes: 4 additions & 4 deletions widget/Rotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ define([
}
_t._domNode.removeChild(removed.node);
}
if (_t.idx > idx) {
_t.idx--;
}
}

var index,
Expand All @@ -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;
}
Expand All @@ -220,9 +223,6 @@ define([
}
else {
removeFromPanes(index);
if (this.idx > index) {
this.idx--;
}
}
},

Expand Down
16 changes: 13 additions & 3 deletions widget/tests/test_Rotator.html
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,17 @@ <h2>Insertion and removal</h2>
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;
Expand All @@ -870,7 +879,8 @@ <h2>Insertion and removal</h2>
<button onclick="myRotator15.next();">Next</button>
<button onclick="myRotator15Insert();">Append</button>
<button onclick="myRotator15Insert(1);">Insert</button>
<button onclick="myRotator15Remove();">Remove</button>
<button onclick="myRotator15RemoveByIndex();">Remove by Index</button>
<button onclick="myRotator15RemoveByNode();">Remove by Node</button>
</p>

<div data-dojo-type="dojox/widget/Rotator" class="rotator" data-dojo-id="myRotator15"
Expand Down

0 comments on commit 8b7a975

Please sign in to comment.