带有全角容器的 jQuery 可拖动
我有一个父 div 容器(全屏宽度),包括一个可拖动的浮动图像列表(连续 5 个图像的宽度为 4086px;)。像这样的东西:
<div id="dragzone">
<div id="draglist">
<!-- BEGIN first row -->
<img src="#" alt="" />
<img src="#" alt="" /> [...]
</div>
</div>
CSS 看起来:
#dragzone{
background: #fff;
height: 630px;
overflow: hidden;
width: 100%;
}
#draglist{
width:4086px;
height: 630px;
cursor: move;
}
draglist img {
float: left;
}
可拖动区域初始化为:
<script language="javascript" type="text/javascript">
$(function() {
$( "#dragzone" ).draggable({
containment : 'parent',
cursor: 'move'
});
});
</script>
^ 不幸的是,上面的代码对我不起作用。除非“draglist”不应在父容器内离开或消失,否则它必须可在 x 轴上拖动。
如果我删除遏制选项,该区域将是可拖动的,但在区域边界(两个轴)之外拖动时会消失。
具体来说:图像列表不应在 y 轴上拖动,但应在 x 轴上移动,并自动停止在列表末尾。
有什么建议来解决这个问题吗?
谢谢杰伊
I have a parent div-container (full-screen width) including a draggable list of floated images (width of 5 images in a row is 4086px;). Something like this:
<div id="dragzone">
<div id="draglist">
<!-- BEGIN first row -->
<img src="#" alt="" />
<img src="#" alt="" /> [...]
</div>
</div>
The CSS looks:
#dragzone{
background: #fff;
height: 630px;
overflow: hidden;
width: 100%;
}
#draglist{
width:4086px;
height: 630px;
cursor: move;
}
draglist img {
float: left;
}
The draggable area is initialised with:
<script language="javascript" type="text/javascript">
$(function() {
$( "#dragzone" ).draggable({
containment : 'parent',
cursor: 'move'
});
});
</script>
^ Unfortunately the above code does not working for me. Unless the "draglist" should not leave nor vanish within the parent container, it otherwise has to be draggable on the x-axis.
If I remove the containment option, the area will be draggable, but disappears being dragged outside the zone`s borders (both axes).
To be concreate at all: The image-list should not be draggable on the y-axis, but moveable on the x-axis, stopping automatically at the end of the list.
Any suggestions to solve this problem?
Thanks Jay
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论