实现自动滚动后奇怪的可拖动行为 [英] Odd Draggable Behavior After Implementing Auto Scroll

查看:114
本文介绍了实现自动滚动后奇怪的可拖动行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 jQuery UI可拖动小部件实现拖放。

我现在正在拖动操作期间实现自动滚动。我进行了设置,以便在您开始拖动时,灰色叠加层会出现在浏览器窗口的顶部和底部。当您拖入其中一个叠加层时,浏览器窗口将开始自动滚动。

I'm now implementing auto scroll during drag operations. I set it up so that when you start to drag, gray overlays appear at the top and bottom of the browser window. When you drag into one of these overlays, the browser window starts to auto scroll.

您可以在 http://www.softcircuits.com/Client/scrolltest.html 。通过拖动左侧的一个十字准线图标来拖动项目。

You can see my test page at http://www.softcircuits.com/Client/scrolltest.html. Drag an item by dragging one of the crosshair icons on the left side.

但是有一个问题:如果滚动到页面底部,然后拖动一个项目在顶部叠加层,它将按预期向上滚动。然而,对我来说,我大约在页面的一半,可拖动的助手不会更高。我无法一直拖到页面顶部。

But there's a problem: if you scroll to the bottom of the page, and then drag an item to the top overlay, it will scroll up as expected. However, for me, I get about half way up the page and the draggable helper won't go any higher. There's no way for me to drag all the way to the top of the page.

这很可能与Draggable小部件有关。有人能够看出为什么会这样吗?我在Windows 7上使用谷歌浏览器。

This most likely seems related to the Draggable widget. Is anyone able to see why this is happening? I'm using Google Chrome on Windows 7.

推荐答案

从窗口更改可拖动的包含选项为我工作。

Changing the draggable containment option from window to document worked for me.

$('.drag-handle').draggable({ 
    ...
    containment: "document",
    ...
});

参见: http://docs.jquery.com/UI/Draggable#option-containment

这篇关于实现自动滚动后奇怪的可拖动行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆