File tree Expand file tree Collapse file tree 3 files changed +26
-12
lines changed Expand file tree Collapse file tree 3 files changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ class Controller {
9292 this . __onChange . call ( this , newValue ) ;
9393 }
9494
95- this . updateDisplay ( ) ;
95+ this . updateDisplay ( true ) ;
9696 return this ;
9797 }
9898
@@ -110,7 +110,7 @@ class Controller {
110110 * with the object's current value.
111111 * @returns {Controller } this
112112 */
113- updateDisplay ( ) {
113+ updateDisplay ( force ) {
114114 return this ;
115115 }
116116
Original file line number Diff line number Diff line change @@ -94,11 +94,24 @@ class NumberControllerBox extends NumberController {
9494 dom . bind ( this . __input , 'mousedown' , onMouseDown ) ;
9595 dom . bind ( this . __input , 'keydown' , function ( e ) {
9696 // 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 ;
102115 }
103116 } ) ;
104117
@@ -107,9 +120,10 @@ class NumberControllerBox extends NumberController {
107120 this . domElement . appendChild ( this . __input ) ;
108121 }
109122
110- updateDisplay ( ) {
123+ updateDisplay ( force ) {
124+ if ( ! force && dom . isActive ( this . __input ) ) return this ;
111125 this . __input . value = this . __truncationSuspended ? this . getValue ( ) : roundToDecimal ( this . getValue ( ) , this . __precision ) ;
112- return super . updateDisplay ( ) ;
126+ return super . updateDisplay ( force ) ;
113127 }
114128}
115129
Original file line number Diff line number Diff line change @@ -75,10 +75,10 @@ class OptionController extends Controller {
7575 return toReturn ;
7676 }
7777
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
8080 this . __select . value = this . getValue ( ) ;
81- return super . updateDisplay ( ) ;
81+ return super . updateDisplay ( force ) ;
8282 }
8383}
8484
You can’t perform that action at this time.
0 commit comments