jQuery可排序和自定义滚动条 [英] jQuery sortable and custom scroll bar

查看:105
本文介绍了jQuery可排序和自定义滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在webapp中使用自定义滚动条,但我遇到以下问题:

http://jsfiddle.net/PVZB8/3056



正如你所看到的,当你将一个项目拖出列表它是隐形的。
我需要使它可见并且是原始项目,因为我有动画触发器绑定到它。



您可以更多地了解我正在尝试执行的操作如果你检查:
jQuery排序溢出:隐藏;在两个列表之间

解决方案

我知道这张票有点过时,但我在使用时遇到同样的问题我的自定义滚动条解决方案,并试图在隐藏溢出的Sortable之间拖动。添加代码修复Sortable以使用我的Scrollpane后,我注意到appendTo功能似乎被省略。



appendTo 如果它不存在于DOM中,那么它只会将帮助器附加到目标。这就是为什么克隆选项适用于某些(但不是所有的,我不会在这里)。修复它的关键是将此代码添加到小部件的 _mouseStart 函数的结尾:

  if(!this.helper.parent()。(this.appendTo)){
this.helper.detach()。appendTo(this.appendTo);
//更新位置
this.offset.parent = this._getParentOffset();
}

请注意,设置 this.appendTo 在前面的函数中:

  this.appendTo = $(o.appendTo!==parent?
o .appendTo:
this.currentItem.parent());

jQuery的scrollsortable JS文件中提供了完整的修复程序,包括其他流修复程序-UI-ScrollPane可在这里找到: https://github.com/borgboyone/jQuery-UI-ScrollPane 。 (注意:此修正已经通过pull-request提供给jQuery-UI项目。)



干杯!


I am using custom scrollbar in my webapp but I have the following problem:

http://jsfiddle.net/PVZB8/3056

As you can see when you drag an item out of the list it is invisible. I need to make it visible and to be original item because I have animation triggers bind to it.

You can understand more of what I am trying to do if you check this: jQuery sortable with overflow: hidden; between two lists

解决方案

I know this ticket is somewhat dated, but I had ran into the same issue while using my custom scrollbar solution and attempting to drag between Sortable's with overflow hidden. After adding code to fix-up Sortable to work with my Scrollpane, I noticed what appeared to be an omission for the appendTo functionality.

The code for appendTo only appends the helper to the target if it doesn't exist in the DOM. That's why the clone options works for some (but not for all and I won't go into that here). The key to fixing it was to add this code toward the end of the _mouseStart function of the widget:

if (!this.helper.parent().is(this.appendTo)) {
    this.helper.detach().appendTo(this.appendTo);
    // update position
    this.offset.parent = this._getParentOffset();
}

Note that this.appendTo is set-up earlier in the function:

this.appendTo = $( o.appendTo !== "parent" ?
        o.appendTo :
        this.currentItem.parent() );

The complete fix-up, including other flow fixes, is available in the scrollsortable JS file for the jQuery-UI-ScrollPane available here: https://github.com/borgboyone/jQuery-UI-ScrollPane. (Note: This fix-up has been made available to the jQuery-UI project via pull-request.)

Cheers!

这篇关于jQuery可排序和自定义滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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