File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,12 @@ var _ = require('lodash');
3
3
var debug = require ( 'debug' ) ( 'scout-ui:minicharts:unique' ) ;
4
4
5
5
module . exports = VizView . extend ( {
6
+ props : {
7
+ timer : {
8
+ type : 'number' ,
9
+ default : null
10
+ }
11
+ } ,
6
12
template : require ( './unique.jade' ) ,
7
13
derived : {
8
14
randomValues : {
@@ -18,16 +24,27 @@ module.exports = VizView.extend({
18
24
}
19
25
} ,
20
26
events : {
21
- 'mousedown [data-hook=refresh]' : 'refresh'
27
+ 'mousedown [data-hook=refresh]' : 'refresh' ,
28
+ 'mouseup' : 'stopTimer'
22
29
} ,
23
30
render : function ( ) {
24
31
this . renderWithTemplate ( this ) ;
25
32
} ,
26
33
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
+ }
30
43
this . render ( ) ;
44
+ } ,
45
+ stopTimer : function ( event ) {
46
+ clearInterval ( this . timer ) ;
47
+ this . timer = null ;
31
48
}
32
49
33
50
} ) ;
You can’t perform that action at this time.
0 commit comments