Skip to content

Commit b6a4cca

Browse files
author
Kai Schlamp
committed
Retain data and bindings on cloned last item.
Some text adjustments as ticker is not very accurate.
1 parent 1264a98 commit b6a4cca

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

tests/unit/ticker/ticker_core.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,27 @@ test("nextItem returns null", function() {
2828
}, 100);
2929
});
3030

31+
test("last item clone retains data and bindings", function() {
32+
expect(3);
33+
stop();
34+
35+
$("#ticker li:last")
36+
.data("test", "123")
37+
.bind("click", function() {});
38+
39+
$("#ticker").ticker({
40+
initialTimeout: 0,
41+
scrollTime: 0,
42+
fadeTime: 0,
43+
nextItem: function(lastItem) {
44+
ok(true, "nextItem is called");
45+
equals(lastItem.data("test"), "123", "last item clone retains data");
46+
ok(lastItem.data("events") != null, "last item clone retains events");
47+
return null;
48+
}
49+
});
50+
51+
window.setTimeout(function() { start(); }, 200);
52+
});
53+
3154
})(jQuery);

tests/unit/ticker/ticker_events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test("afterFade", function() {
6464
}
6565
});
6666

67-
window.setTimeout(function() { start(); }, 200);
67+
window.setTimeout(function() { start(); }, 300);
6868
});
6969

7070
test("correct order of nextItem call and events", function() {

tests/unit/ticker/ticker_methods.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,21 @@ test("start", function() {
8585
var started = false;
8686

8787
$("#ticker").ticker({
88-
initialTimeout: 100,
89-
mouseOnTimeout: 100,
90-
mouseOffTimeout: 100,
91-
scrollTime: 0,
92-
fadeTime: 0,
88+
active: false,
89+
initialTimeout: 0,
9390
nextItem: function(lastItem) {
9491
if (started) {
9592
ok(true, "ticker scrolled after it was started");
9693
$("#ticker").ticker("stop");
9794
}
95+
else {
96+
ok(false, "ticker scrolled without being started");
97+
}
98+
9899
}
99100
});
100-
$("#ticker").ticker("stop");
101101
window.setTimeout(function() { started = true; $("#ticker").ticker("start"); }, 200);
102-
window.setTimeout(function() { start(); }, 500);
102+
window.setTimeout(function() { start(); }, 600);
103103
});
104104

105105
})(jQuery);

tests/unit/ticker/ticker_options.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ test("{mouseOffTimeout: 100}", function() {
8181
}
8282
});
8383

84-
window.setTimeout(function() { start(); }, 300 );
84+
window.setTimeout(function() { start(); }, 400 );
8585
});
8686

8787
test("{mouseOnTimeout: 100}", function() {
@@ -107,7 +107,7 @@ test("{mouseOnTimeout: 100}", function() {
107107
});
108108

109109
$("#ticker").simulate("mouseover");
110-
window.setTimeout(function() { start(); }, 300 );
110+
window.setTimeout(function() { start(); }, 400 );
111111
});
112112

113113
test('{nextItem: function() {return $("TestItem")}}', function() {

0 commit comments

Comments
 (0)