gpt4 book ai didi

javascript - 对数 slider 返回 NaN

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:34:35 30 4
gpt4 key购买 nike

我正在尝试按照 Logarithmic slider 中的示例进行操作.

这是我使用的代码:

Timeline._MIN_PER_MINUTE = 1;
Timeline._MIN_PER_HOUR = Timeline._MIN_PER_MINUTE * 60.0;
Timeline._MIN_PER_DAY = Timeline._MIN_PER_HOUR * 24.0;
Timeline._MIN_PER_WEEK = Timeline._MIN_PER_DAY * 7.0;
Timeline._MIN_PER_MONTH = Timeline._MIN_PER_WEEK * 4.0;
Timeline._MIN_PER_YEAR = Timeline._MIN_PER_MONTH * 12.0;

var scale_down = 0.00001;
var scale_up = 100000;
Timeline._SLIDER_MIN = 0;
Timeline._SlIDER_MAX = 100;
Timeline._SLIDER_STEP = 1;

Timeline._scale = function (value) {
var minIn = Timeline._SLIDER_MIN;
var maxIn = Timeline._SLIDER_MAX;

var minOut = Math.log(Timeline._MIN_PER_MINUTE);
var maxOut = Math.log(Timeline._MIN_PER_YEAR);

var scale = (maxOut - minOut) / (maxIn - minIn);

return Math.exp(minOut + scale * (value - minIn));
};

Timeline._sliderChangedHandler = function(id){
var val = Timeline._scale($('#scale_slider' + id).val());
alert(val);
};

出于某种原因,结果我得到了 NaN。有人知道我做错了什么吗?

最佳答案

用这个var val = Timeline._scale(parseInt($('#scale_slider' + id).val(), 10));

关于javascript - 对数 slider 返回 NaN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4790376/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com