有什么想法可以检测超出 jquery-ui 可拖动内容范围的鼠标事件吗?
我刚刚制作了一个可拖动的 div,如下所示: .draggable({ axis: 'x', contains: [ pLeft+margin, 0, pWidth-(margin*2), 0] }).css('opacity', 0.6)我可以看到 div 覆盖在父级上,并且可以在父级内沿 x 轴拖动,距左右边缘(距边距)几个像素。这就是场景。
问题
如何检测超出遏制范围的可拖动事件以及用户是否试图超越并向左还是向右侧(所以我可以更改父 div 的背景位置,使其具有滚动效果)
有什么想法可以检测超出 jquery-ui 可拖动内容范围的鼠标事件吗? (以及是否向左或向右的信息)?
I just made a div draggable, as in: .draggable({ axis: 'x', containment: [ pLeft+margin, 0, pWidth-(margin*2), 0] }).css('opacity', 0.6) and I can see the div overlayed over the parent and draggable along the x axis within the parent a few pixels away from left and right edge (from margin). This is the scenario.
Question
How do I detect draggable events beyond the containment and whether the user is trying to go beyond and towards the left or towards the right (so I can change the background-position of the parent div giving it a scrolling effect)
Any ideas how I can detect mouse events beyond containment for a jquery-ui draggable? (along with an info whether it is towards left or right)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过在它非常接近边缘时添加一个计时器来解决这个问题,并让内容根据计时器在内部滚动,只要鼠标位于安全壳的左端或右端“外部”。当鼠标回到安全壳的 x 轴范围内时,我重置了计时器。
I resolved this by adding a timer when it reaches very near to edge and made the contents scroll inside based on the timer, as long as the mouse is "outside" the containment's left or right extreme. I reset the timer when the mouse is back inside the containment's x-axis scope.