简体   繁体   English

jQuery ui draggable和bxslider无法正常工作

[英]jquery ui draggable and bxslider not working

i have slider in bxSlider, and the item of the slider is draggable using jquery ui. 我在bxSlider中有滑块,并且可以使用jquery ui拖动滑块的项目。

for better understanding, here is the slider in action http://comicedu.com/htmlcropper/v2/ 为了更好地理解,以下是实际使用的滑块http://comicedu.com/htmlcropper/v2/

try to drag the dog in dogs tab to the background (brick) you will see the dog now inside the brick, then move to cats tab, after that click the left arrow then drag the 3rd image and now you will see the draggable is not working, what is wrong with that? 尝试将“狗”选项卡中的狗拖动到背景(砖),您将看到狗现在位于砖块中,然后移至“猫”选项卡,然后单击向左箭头然后拖动第三张图片,现在您将看到可拖动的工作,这有什么问题? i investigate that bxSlider add bx-clone class to the container div. 我调查了bxSlider将bx-clone类添加到容器div中。

This is just a guess, but it looks like to me, jquery is attaching the drag and drop events first to the 'true' (not cloned) images, then bxslider is creating the clones AFTER jquery has registered the images for drag and drop, so the cloned images aren't being attached to the drag/drop events? 这只是一个猜测,但在我看来,jquery首先将拖放事件附加到“ true”(未克隆)图像上,然后bxslider在jquery注册了用于拖放的图像后创建克隆,因此克隆的图像不会附加到拖放事件中吗?

Try loading things in order. 尝试按顺序加载东西。

$(function(){
    loadSlider();
    loadDragDrop();
};

function loadSlider{
    //Load the slider
}

function loadDragDrop(){
    //Load the drag/drop
}

OR Attach the drag/drop on page load as you are now, then try re-attaching the drag/drop on this event of the bxslider: 或者像现在一样,将拖放添加到页面加载中,然后尝试在bxslider的此事件上重新添加拖放:

onSlideAfter: function() {},

Hopefully this will force the drag/drop to be added to clones as well since they would have been created by the slider already. 希望这将强制将拖放操作也添加到克隆中,因为它们已经由滑块创建了。

Clones are created to fill in the empty slots in your slider. 将创建克隆以填充滑块中的空白插槽。 say your slider can fit 6 images and you have 8 images, 4 clones will be created so when you skip to the second group, the slider is full. 假设您的滑杆可以容纳6张图像,而您有8张图像,则会创建4个克隆,因此当您跳到第二组时,滑杆已满。

If my guess is way off (and it could be), you can do 2 things to 'quick' fix until a better sloution comes along: 如果我的猜测还没有结束(可能是这样),您可以做两件事来“快速”解决问题,直到出现更好的情况:

  1. Hide any bx-clone elements with css 用CSS隐藏任何bx-clone元素

    .bx-clone { display:none; .bx-clone {display:none; } }

  2. Make sure you have the correct amount of images to fill the slider. 确保您有正确数量的图像来填充滑块。 For cats, it looks like you have 10 images, the others are clones, so make the number of cat images 16 so the slider doesn't have to create any clones. 对于猫来说,看起来您有10个图像,其他图像是克隆图像,因此将猫图像的数量设置为16,因此滑块无需创建任何克隆图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM