当滑块位于多重地图上方时,Scriptaculous 滑块手柄不会移动

发布于 2024-08-22 15:18:47 字数 818 浏览 8 评论 0原文

我有一个 Scriptaculous Slider 显示在 多地图。我遇到的问题是,在此页面上,如果您尝试拖动滑块手柄,它不会移动。如果我单击滑块轨道,手柄会正确跳转到该点,然后您可以使用手柄正确拖动。

单击手柄成功注册了单击,因为我可以 console.log() 滑块此时的值。尝试通过手柄拖动滑块只会不断记录相同的值,并且手柄不会移动。

滑块在任何没有多重贴图的页面上都能正常工作。

页面上没有其他 JS 框架(只有 Prototype 和 Scriptaculous)。

我真的不确定问题所在。如果滑块没有注册任何内容,那么地图以某种方式位于顶部或窃取了点击事件就有意义了。但点击次数显然是被记录的。我也不明白为什么单击滑块轨道可以完全解决问题。

有人可以给我指出正确的方向(无论是修复,还是自己调试问题的路径)。

我尝试过的事情:

  • 设置手柄的 z-index 。
  • 使模态对话框一开始就可见(因为它一开始是隐藏的 - 我认为它可能与 这个问题,但没有帮助)。

I have a Scriptaculous Slider showing in a modal-dialog window above a Multimap. The problem that I'm having is that on this page the slider handle doesn't move if you try to drag it. If I click on the slider track, the handle correctly jumps to that point and you can then use the handle to drag correctly.

Clicking on the handle successfully registers the click as I can console.log() the value of the slider at that point. Trying to drag the slider around by it's handle just keeps logging that same value and the handle doesn't move.

The slider works correctly on any page that doesn't have the multimap on it.

There are no other JS frameworks on the pages (just Prototype and Scriptaculous).

I'm really not sure that the problem is though. If the slider wasn't registering anything then that would make sense that the map was ontop somehow or stealing the click event. But the clicks are obviously being recorded. I also don't understand why clicking on the slider track fixes the issue completely.

Can someone point me in the right direction (either with a fix, or a path to take to debug the issue myself).

Things I have tried:

  • Setting the z-index of the handle.
  • Making the modal-dialog visible to begin with (as it is hidden to start with - I thought it might be related to this issue, but it didn't help).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪心 2024-08-29 15:18:47

发现问题了。

Scriptaculous Slider 和 Multimap 都定义了 Array.prototype.indexOf,但方式不同。

解决方案(因为我只想在滑块上有 1 个句柄)是编辑 slider.js 并将调用更改为 this.handles.indexOf

Index: slider.js
===================================================================
--- slider.js   (revision 1)
+++ slider.js   (working copy)
@@ -219,14 +219,14 @@
           this.offsetY = (pointer[1] - offsets[1]);
         } else {
           // find the handle (prevents issues with Safari)
-          while((this.handles.indexOf(handle) == -1) && handle.parentNode) 
+          while((this.handles[0] != handle) && handle.parentNode)
             handle = handle.parentNode;
-            
-          if (this.handles.indexOf(handle)!=-1) {
+
+          if (this.handles[0] == handle) {
             this.activeHandle    = handle;
-            this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
+            this.activeHandleIdx = 0;
             this.updateStyles();
-            
+
             var offsets  = Position.cumulativeOffset(this.activeHandle);
             this.offsetX = (pointer[0] - offsets[0]);
             this.offsetY = (pointer[1] - offsets[1]);

使用此修复程序的任何人请注意:虽然此修复程序将使 Scriptaculous Slider 和 Multimaps 可以在同一页面上协同工作,但它只会使滑块上只有 1 个手柄起作用。我还没有测试过如果您尝试将其与 2 个或更多手柄一起使用会发生什么。

Found the problem.

Both the Scriptaculous Slider and Multimap were defining Array.prototype.indexOf but in different ways.

The solution (since I only wanted 1 handle on the slider) was to edit slider.js and change the calls to this.handles.indexOf.

Index: slider.js
===================================================================
--- slider.js   (revision 1)
+++ slider.js   (working copy)
@@ -219,14 +219,14 @@
           this.offsetY = (pointer[1] - offsets[1]);
         } else {
           // find the handle (prevents issues with Safari)
-          while((this.handles.indexOf(handle) == -1) && handle.parentNode) 
+          while((this.handles[0] != handle) && handle.parentNode)
             handle = handle.parentNode;
-            
-          if (this.handles.indexOf(handle)!=-1) {
+
+          if (this.handles[0] == handle) {
             this.activeHandle    = handle;
-            this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
+            this.activeHandleIdx = 0;
             this.updateStyles();
-            
+
             var offsets  = Position.cumulativeOffset(this.activeHandle);
             this.offsetX = (pointer[0] - offsets[0]);
             this.offsetY = (pointer[1] - offsets[1]);

Note to anyone using this fix: While this fix will make it so that the Scriptaculous Slider and Multimaps can work together on the same page, it will make it so that only 1 handle on the slider works. I have not tested what happens if you try to use this with 2 or more handles.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文