循环直到 jQuery mouseenter();发生并且当鼠标按下时
你会如何解决这个问题? 它应该在鼠标按钮按下并且鼠标离开 (#List) 时滚动...
这就是我同时所做的,但我不知道如何检查 jQuery mouseenter 事件是否发生以及鼠标按钮是否按下...
$('#List').mouseleave(function(){
var api = $(scrollPane).data('jsp');
while ( ??? ){
api.scrollByY(50, false);
}
});
有什么建议吗?
How would you solve that?
It should be scrolling while the mousebutton is down and the mouse left the (#List) ...
That's what i have done meanwhile, but i don't know how to check, if the jQuery mouseenter event occured and if the mousebutton is down ...
$('#List').mouseleave(function(){
var api = $(scrollPane).data('jsp');
while ( ??? ){
api.scrollByY(50, false);
}
});
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
永远、永远不要将 Javascript 置于“繁忙”循环中。它会使您的浏览器无响应。
假设你想要的东西是可能的(我不确定它是不是,因为在一个元素中开始并在另一个元素中结束的事件很棘手),你需要类似的东西:
NB:未经测试,可能不起作用,遗漏和错误可能等等
Never, ever, put Javascript into a "busy" loop. It will make your browser unresponsive.
Assuming that what you want is possible (I'm not sure it is, since events that start in one element and finish in another are tricky), you'll need to something like:
NB: untested, may not work, omissions and errors likely, etc.
感谢您的快速答复!在研究了很多 event 和 setInterval 的东西之后,我对这个主题有了更多的了解...但仍然有一件事:无论我按住什么,
ev.which
总是“1”是否离开“#List”时按下鼠标左键...当我按住鼠标右键或中键时,它会变为 2 和 3 ...与事件属性按钮相同,按住鼠标左键与否...Thank you for your quick answer! After studying a lot event and setInterval stuff i know a lot more about this topic ... but still one thing:
ev.which
is always "1" wheter i hold down the left mouse button while leaving the "#List" or not ... when i hold down the right or the middle mouse button it changes to 2 and 3 ... same with the event property button it does not make a difference holding the left mouse button or not ...