jQuery 滑块问题达到最小值和最大值
我初始化了一个 jQuery 滑块,然后根据 json 请求的内容动态设置最小最大值。步数甚至 100、最小和最大都会重新计算为甚至一百,大多数情况下在 300 到 4800 之间。
滑块值和设置都很好,但当我移动手柄时,我无法将其一直移动到结束时,它会从最小/最大值停止几步。这是为什么?
我已经尝试了各种方法,但没有任何作用。我最终在最高值处加上 200,并在较低值处减去 200 来进行补偿,但这是一种 hack,而不是解决方案。
I have a jQuery slider initialized and then dynamically set min max values depeding on the contents of a json-request. Steps av even 100, min a max are recalculated to even hundred, most of the case somewhere between 300 and 4800.
The slider values and settings are fine, but when I move the handle I can't get it all the way out to the ends, it stops a few steps from min/max values. Why is that?
I've tried all sorts of things, nothing works. I ended up adding 200 at the top value and subtracting 200 in the lower and to compensate, but that's is a hack and not a solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在“幻灯片”回调中,尝试使用 ui.value 来获取值。这解决了我的问题。看
jQuery UI 滑块 - 无法滑动到 0 除非不按照答案,按照答案的评论。
In your 'slide' callback, try using ui.value to get the value. This solved my problem. See
jQuery UI slider - can't slide to 0 except don't go by the answer, go by the comment to the answer.
我意识到这个问题已经有 5 年历史了,但我今天刚刚遇到了类似的问题。我有一个有很多步长的短滑块,它从 0 到 1,步长为 0.01。滑块手柄会在碰到最外面的台阶之前撞到滑块的末端,因此我只能向下至 0.02 向上至 0.98。
如果有人遇到这个问题,一个快速的解决方法就是简单地让您的最小值和最大值比应有的值稍微远一点,并在用户滑过它们时调整您的值。
I realise this question is 5 years old but I just encountered a similar problem today. I had a short slider with many steps, it went from 0 to 1 with steps of 0.01. The slider handle would bump into the ends of the slider before hitting the outermost steps, so I could only go down to 0.02 and up to 0.98.
If anyone runs into this problem, a quick work-around is to simply make your min and max values go a little further than they should and adjust your value if the user slides past them.
我对这些设置也有类似的问题
,滑块最多只能达到 149999.74。当然,就我而言,问题是给定步骤 1 和未均匀划分为这些步骤的范围,滑块永远无法达到最终值之一。
将分钟更改为 35000 (Math.floor()),一切都非常顺利。
I had a similar problem with these settings
and the slider only went as far as 149999.74. Of course, in my case the problem was that given the step 1 and a range that does not divide evenly into these steps, one of the end values could never be reached with a slider.
Changed the min to be 35000 (Math.floor()) and everything worked like a charm.