File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,10 +233,37 @@ class ListWidget extends React.Component {
233233}
234234
235235class ButtonForCounter extends React . Component {
236+ constructor ( props ) {
237+ super ( props ) ;
238+
239+ this . _onCountStart = ( ) => {
240+ this . _flagCount = true ;
241+
242+ const doCount = ( ) => {
243+ if ( ! this . _flagCount ) {
244+ return ;
245+ }
246+
247+ this . props . onCount ( ) ;
248+
249+ setTimeout ( doCount , 25 ) ;
250+ } ;
251+
252+ doCount ( ) ;
253+ } ;
254+
255+ this . _onCountStop = ( ) => {
256+ this . _flagCount = false ;
257+ } ;
258+ }
259+
236260 render ( ) {
237- return ( < button onClick = { ( ) => {
238- this . props . onCount ( ) ;
239- } } > { this . props . caption } </ button > ) ;
261+ return ( < button onMouseDown = { this . _onCountStart }
262+ onMouseUp = { this . _onCountStop }
263+ onMouseLeave = { this . _onCountStop }
264+ onTouchStart = { this . _onCountStart }
265+ onTouchEnd = { this . _onCountStop }
266+ onTouchCancel = { this . _onCountStop } > { this . props . caption } </ button > ) ;
240267 }
241268}
242269
You can’t perform that action at this time.
0 commit comments