Skip to content

Commit 34b98e2

Browse files
committed
fix isNaN bug
1 parent 2601065 commit 34b98e2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

examples/simple.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
<p>
1515
<span class="counter" data-direction="down">0:10</span>
1616
</p>
17+
<p>
18+
<span class="counter" data-direction="up" data-interval="1" data-format="9999" data-stop="2012">0</span>
19+
</p>
1720
<p>
1821
<span class="counter" data-direction="up" data-format="23:59:59.9" data-stop="00:00:10.0" data-interval="100">0:00.0</span>
1922
</p>
2023
<p>
21-
<span class="counter" data-direction="up" data-format="300" data-stop="300" data-interval="100">0</span>
24+
<span class="counter" data-direction="up" data-format="1 1 1 1 1 1 1 1" data-stop="0 0 1 0 0 0 0 0" data-interval="100">0</span>
2225
</p>
2326
<p>Initialization</p>
2427
<pre>

src/jquery.counter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
part.value += data.down ? -1 : 1;
3030
if (data.down && part.value < 0) {
3131
part.value = part.limit;
32-
} else if (!data.down && part.value > part.limit) {
33-
part.value = 0;
32+
} else if (!data.down && part.value > part.limit) {
33+
part.value = 0;
3434
} else {
3535
break;
3636
}
@@ -80,7 +80,7 @@
8080
}
8181
e.html('');
8282
$.each(format, function(index, value) {
83-
if (!isNaN(value)) {
83+
if (/^\d+$/.test(value)) {
8484
var part = {};
8585
part.index = index;
8686
part.padding = (value + '').length;

0 commit comments

Comments
 (0)