File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -156,14 +156,15 @@ <h1>jQuery Knob</h1>
156156 < input class ="knob " data-angleOffset =-125 data-angleArc =250 data-fgColor ="#66EE66 " data-rotation ="anticlockwise " value ="35 ">
157157 </ div >
158158 < div class ="demo " >
159- < p > × 5 -digit values , step 1000 </ p >
159+ < p > × 4 -digit, step 0.1 </ p >
160160 < pre >
161- data-step="1000"
162- data-min="-15000"
163- data-max="15000"
161+ data-step=".1"
162+ data-min="-10000"
163+ data-max="10000"
164+ value="0"
164165data-displayPrevious=true
165166 </ pre >
166- < input class ="knob " data-min ="-15000 " data-displayPrevious =true data-max ="15000 " data-step ="1000 " value ="-11000 ">
167+ < input class ="knob " data-min ="-10000 " data-displayPrevious =true data-max ="10000 " data-step =".1 " value ="0 ">
167168 </ div >
168169 < div style ="clear:both "> </ div >
169170 < div style ="text-align: center ">
Original file line number Diff line number Diff line change 156156 function ( ) {
157157 var val = { } ;
158158 val [ k ] = $this . val ( ) ;
159- s . val ( val ) ;
159+ s . val ( s . _validate ( val ) ) ;
160160 }
161161 ) ;
162162 } ) ;
452452 } ;
453453
454454 this . _validate = function ( v ) {
455- return ( ~ ~ ( ( ( v < 0 ) ? - 0.5 : 0.5 ) + ( v / this . o . step ) ) ) * this . o . step ;
455+ var val = ( ~ ~ ( ( ( v < 0 ) ? - 0.5 : 0.5 ) + ( v / this . o . step ) ) ) * this . o . step ;
456+ return Math . round ( val * 100 ) / 100 ;
456457 } ;
457458
458459 // Abstract methods
549550 a += this . PI2 ;
550551 }
551552
552- ret = ~ ~ ( 0.5 + ( a * ( this . o . max - this . o . min ) / this . angleArc ) ) + this . o . min ;
553+ ret = ( a * ( this . o . max - this . o . min ) / this . angleArc ) + this . o . min ;
553554
554555 this . o . stopper && ( ret = max ( min ( ret , this . o . max ) , this . o . min ) ) ;
555556
635636 var v = s . o . parse ( s . $ . val ( ) ) + kv [ kc ] * m ;
636637 s . o . stopper && ( v = max ( min ( v , s . o . max ) , s . o . min ) ) ;
637638
638- s . change ( v ) ;
639+ s . change ( s . _validate ( v ) ) ;
639640 s . _draw ( ) ;
640641
641642 // long time keydown speed-up
You can’t perform that action at this time.
0 commit comments