简体   繁体   English

鼠标离开滑块控件后调用JavaScript函数吗?

[英]Call a javascript function after the slider control is left from mouse?

I am using the slider control from WebFX . 我正在使用WebFX的滑块控件。 I want to invoke a function called process() after the slider is dragged in mouse and left. 我想在向左和向左拖动滑块后调用一个名为process()的函数。 I used the following code: 我使用以下代码:

var s1 = new Slider(document.getElementById("slider-1"), document.getElementById("slider-input-1"),"vertical");
s1.onchange= function()
{
process();
}

But the problem here is the function is called on a single value change in the slider. 但是这里的问题是在滑块中的单个值更改上调用了该函数。 That is , when we click and drag the slider it calls the function for every change in value. 也就是说,当我们单击并拖动滑块时,它会在每次更改值时调用该函数。
But what I want is to invoke the function only when the slider is left after dragging. 但是我想要的是仅在拖动后留下滑块时才调用该函数。 Not invoke the function for each change while dragging the slider control. 拖动滑块控件时,不要为每个更改调用函数。

How to accomplish this? 如何做到这一点?

look for onchanged event! 寻找变化莫测的事件! There must be s1.onchanged 必须是s1.onchanged

Helped myself with onmouseup mouse event on the div that contains the slider. 顺手拿与onmouseup在包含滑块的div鼠标事件。 And that helped but with a small flaw. 这有所帮助,但有一个小缺陷。
When the user drags the mouse holding the slider and releases the mouse after moving out of the div containing the slider the event is not generated. 当用户拖动鼠标并按住滑块并在移出包含滑块的div后释放鼠标时,不会生成事件。

Any other solution overcoming this flaw would be good. 任何其他解决此缺陷的解决方案都将是不错的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM