File tree 3 files changed +26
-12
lines changed
3 files changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ class Controller {
92
92
this . __onChange . call ( this , newValue ) ;
93
93
}
94
94
95
- this . updateDisplay ( ) ;
95
+ this . updateDisplay ( true ) ;
96
96
return this ;
97
97
}
98
98
@@ -110,7 +110,7 @@ class Controller {
110
110
* with the object's current value.
111
111
* @returns {Controller } this
112
112
*/
113
- updateDisplay ( ) {
113
+ updateDisplay ( force ) {
114
114
return this ;
115
115
}
116
116
Original file line number Diff line number Diff line change @@ -94,11 +94,24 @@ class NumberControllerBox extends NumberController {
94
94
dom . bind ( this . __input , 'mousedown' , onMouseDown ) ;
95
95
dom . bind ( this . __input , 'keydown' , function ( e ) {
96
96
// When pressing enter, you can be as precise as you want.
97
- if ( e . keyCode === 13 ) {
98
- _this . __truncationSuspended = true ;
99
- this . blur ( ) ;
100
- _this . __truncationSuspended = false ;
101
- onFinish ( ) ;
97
+ const step = _this . __step || 1 ;
98
+ switch ( e . keyCode ) {
99
+ case 13 :
100
+ _this . __truncationSuspended = true ;
101
+ this . blur ( ) ;
102
+ _this . __truncationSuspended = false ;
103
+ onFinish ( ) ;
104
+ break ;
105
+ case 38 :
106
+ const newVal1 = _this . getValue ( ) + step ;
107
+ _this . setValue ( newVal1 ) ;
108
+ break ;
109
+ case 40 : // down
110
+ const newVal2 = _this . getValue ( ) - step ;
111
+ _this . setValue ( newVal2 ) ;
112
+ break ;
113
+ default :
114
+ break ;
102
115
}
103
116
} ) ;
104
117
@@ -107,9 +120,10 @@ class NumberControllerBox extends NumberController {
107
120
this . domElement . appendChild ( this . __input ) ;
108
121
}
109
122
110
- updateDisplay ( ) {
123
+ updateDisplay ( force ) {
124
+ if ( ! force && dom . isActive ( this . __input ) ) return this ;
111
125
this . __input . value = this . __truncationSuspended ? this . getValue ( ) : roundToDecimal ( this . getValue ( ) , this . __precision ) ;
112
- return super . updateDisplay ( ) ;
126
+ return super . updateDisplay ( force ) ;
113
127
}
114
128
}
115
129
Original file line number Diff line number Diff line change @@ -75,10 +75,10 @@ class OptionController extends Controller {
75
75
return toReturn ;
76
76
}
77
77
78
- updateDisplay ( ) {
79
- if ( dom . isActive ( this . __select ) ) return this ; // prevent number from updating if user is trying to manually update
78
+ updateDisplay ( force ) {
79
+ if ( ! force && dom . isActive ( this . __select ) ) return this ; // prevent number from updating if user is trying to manually update
80
80
this . __select . value = this . getValue ( ) ;
81
- return super . updateDisplay ( ) ;
81
+ return super . updateDisplay ( force ) ;
82
82
}
83
83
}
84
84
You can’t perform that action at this time.
0 commit comments