Skip to content

Commit c46f47a

Browse files
rueckstiesskangas
authored andcommitted
spin the "wheel of fortune" in unique minichart.
debounced interval to shuffle random values on mousedown.
1 parent 69de0ec commit c46f47a

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

scout-ui/src/minicharts/unique.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ var _ = require('lodash');
33
var debug = require('debug')('scout-ui:minicharts:unique');
44

55
module.exports = VizView.extend({
6+
props: {
7+
timer: {
8+
type: 'number',
9+
default: null
10+
}
11+
},
612
template: require('./unique.jade'),
713
derived: {
814
randomValues: {
@@ -18,16 +24,27 @@ module.exports = VizView.extend({
1824
}
1925
},
2026
events: {
21-
'mousedown [data-hook=refresh]': 'refresh'
27+
'mousedown [data-hook=refresh]': 'refresh',
28+
'mouseup': 'stopTimer'
2229
},
2330
render: function() {
2431
this.renderWithTemplate(this);
2532
},
2633
refresh: function(event) {
27-
debug('refresh clicked');
28-
event.stopPropagation();
29-
event.preventDefault();
34+
if (!this.timer) {
35+
this.timer = setInterval(this.refresh.bind(this), 600);
36+
} else {
37+
clearInterval(this.timer);
38+
this.timer = setInterval(this.refresh.bind(this), 50);
39+
}
40+
if (event) {
41+
event.preventDefault();
42+
}
3043
this.render();
44+
},
45+
stopTimer: function(event) {
46+
clearInterval(this.timer);
47+
this.timer = null;
3148
}
3249

3350
});

0 commit comments

Comments
 (0)