我不认为这是一个错误,很抱歉,它只是四舍五入 - 我认为这是spinner.js中的 jQuery 代码中的部分,用于操作四舍五入:
期间_spin()
:
value = this._adjustValue( value + step * this._increment( this.counter ) );
来电_adjustValue()
:
_adjustValue: function( value ) {
var base, aboveMin,
options = this.options;
// make sure we're at a valid step
// - find out where we are relative to the base (min or 0)
base = options.min !== null ? options.min : 0;
aboveMin = value - base;
// - round to the nearest step
aboveMin = Math.round(aboveMin / options.step) * options.step;
// - rounding is based on 0, so adjust back to our base
value = base + aboveMin;
// fix precision from bad JS floating point math
value = parseFloat( value.toFixed( this._precision() ) );
// clamp the value
if ( options.max !== null && value > options.max) {
return options.max;
}
if ( options.min !== null && value < options.min ) {
return options.min;
}
return value;
},
来源:jQuery UI GitHub
但是您可以尝试的是,在旋转之前捕获该值,然后在完成旋转后重新调整该值,基于您之前通过以下两个回调事件获得的值:
var beforeSpin = 1.00;
$( "#spinner" ).spinner({
step: 1.10,
numberFormat: "n",
start: function( event, ui ) {
beforeSpin = ui.value;
},
//or stop: function(){}
spin: function( event, ui ) {
//Do some re-value
//funciton based on old value
}
});
那,或者根据您的需要重新编程_adjustValue: function()
- 毕竟是开源的:)