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');
33var debug = require ( 'debug' ) ( 'scout-ui:minicharts:unique' ) ;
44
55module . 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} ) ;
You can’t perform that action at this time.
0 commit comments