Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
leizi929
Sortable
提交
473f5286
S
Sortable
项目概览
leizi929
/
Sortable
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Sortable
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
473f5286
编写于
5月 01, 2021
作者:
O
Owen Mills
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP
上级
0656d624
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
30 addition
and
16 deletion
+30
-16
src/Sortable.js
src/Sortable.js
+14
-12
src/utils.js
src/utils.js
+16
-4
未找到文件。
src/Sortable.js
浏览文件 @
473f5286
...
...
@@ -34,7 +34,8 @@ import {
throttle
,
scrollBy
,
clone
,
expando
expando
,
getParentSortable
}
from
'
./utils.js
'
;
...
...
@@ -334,7 +335,7 @@ let nearestEmptyInsertDetectEvent = function(evt) {
let
_checkOutsideTargetEl
=
function
(
evt
)
{
if
(
dragEl
)
{
dragEl
.
parentNode
[
expando
]
.
_isOutsideThisEl
(
evt
.
target
);
getParentSortable
(
dragEl
)
.
_isOutsideThisEl
(
evt
.
target
);
}
};
...
...
@@ -560,11 +561,11 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
ownerDocument
=
el
.
ownerDocument
,
dragStartFn
;
if
(
target
&&
!
dragEl
&&
(
target
.
parentNode
===
el
)
)
{
if
(
target
&&
!
dragEl
&&
getParentSortable
(
target
)
===
this
)
{
let
dragRect
=
getRect
(
target
);
rootEl
=
el
;
dragEl
=
target
;
parentEl
=
dragEl
.
parentNode
;
parentEl
=
getParentSortable
(
dragEl
).
el
;
nextEl
=
dragEl
.
nextSibling
;
lastDownEl
=
target
;
activeGroup
=
options
.
group
;
...
...
@@ -758,7 +759,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
parent
=
target
;
}
dragEl
.
parentNode
[
expando
]
.
_isOutsideThisEl
(
target
);
getParentSortable
(
dragEl
)
.
_isOutsideThisEl
(
target
);
if
(
parent
)
{
do
{
...
...
@@ -1083,7 +1084,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
// no bubbling and not fallback
if
(
!
options
.
dragoverBubble
&&
!
evt
.
rootEl
&&
target
!==
document
)
{
dragEl
.
parentNode
[
expando
]
.
_isOutsideThisEl
(
evt
.
target
);
getParentSortable
(
dragEl
)
.
_isOutsideThisEl
(
evt
.
target
);
// Do not detect for empty insert if already inserted
!
insertion
&&
nearestEmptyInsertDetectEvent
(
evt
);
...
...
@@ -1193,16 +1194,17 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
return
completed
(
true
);
}
}
else
if
(
target
.
parentNode
===
el
)
{
else
if
(
getParentSortable
(
target
)
===
this
)
{
targetRect
=
getRect
(
target
);
let
direction
=
0
,
targetBeforeFirstSwap
,
differentLevel
=
dragEl
.
parentNode
!==
el
,
differentLevel
=
getParentSortable
(
dragEl
).
el
!==
el
,
differentRowCol
=
!
_dragElInRowColumn
(
dragEl
.
animated
&&
dragEl
.
toRect
||
dragRect
,
target
.
animated
&&
target
.
toRect
||
targetRect
,
vertical
),
side1
=
vertical
?
'
top
'
:
'
left
'
,
scrolledPastTop
=
isScrolledPast
(
target
,
'
top
'
,
'
top
'
)
||
isScrolledPast
(
dragEl
,
'
top
'
,
'
top
'
),
scrollBefore
=
scrolledPastTop
?
scrolledPastTop
.
scrollTop
:
void
0
;
console
.
log
(
differentLevel
)
if
(
lastTarget
!==
target
)
{
targetBeforeFirstSwap
=
targetRect
[
side1
];
...
...
@@ -1226,7 +1228,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
do
{
dragIndex
-=
direction
;
sibling
=
parentEl
.
children
[
dragIndex
];
sibling
=
dragEl
.
parentNode
.
children
[
dragIndex
];
}
while
(
sibling
&&
(
css
(
sibling
,
'
display
'
)
===
'
none
'
||
sibling
===
ghostEl
));
}
// If dragEl is already beside target: Do not insert
...
...
@@ -1269,7 +1271,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
scrollBy
(
scrolledPastTop
,
0
,
scrollBefore
-
scrolledPastTop
.
scrollTop
);
}
parentEl
=
dragEl
.
parentNode
;
// actualization
parentEl
=
getParentSortable
(
dragEl
).
el
;
// actualization
// must be done before animation
if
(
targetBeforeFirstSwap
!==
undefined
&&
!
isCircumstantialInvert
)
{
...
...
@@ -1322,7 +1324,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
evt
});
parentEl
=
dragEl
&&
dragEl
.
parentNode
;
parentEl
=
dragEl
&&
getParentSortable
(
dragEl
)
;
// Get again after plugin event
newIndex
=
index
(
dragEl
);
...
...
@@ -1694,7 +1696,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
if
(
Sortable
.
eventCanceled
)
return
;
// show clone at dragEl or original position
if
(
dragEl
.
parentNode
==
rootEl
&&
!
this
.
options
.
group
.
revertClone
)
{
if
(
getParentSortable
(
dragEl
)
==
rootEl
&&
!
this
.
options
.
group
.
revertClone
)
{
rootEl
.
insertBefore
(
cloneEl
,
dragEl
);
}
else
if
(
nextEl
)
{
rootEl
.
insertBefore
(
cloneEl
,
nextEl
);
...
...
src/utils.js
浏览文件 @
473f5286
...
...
@@ -68,6 +68,16 @@ function closest(/**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, i
return
null
;
}
function
getParentSortable
(
target
)
{
while
(
target
=
getParentOrHost
(
target
))
{
if
(
target
[
expando
])
{
return
target
[
expando
];
}
}
return
null
;
}
const
R_SPACE
=
/
\s
+/g
;
function
toggleClass
(
el
,
name
,
state
)
{
...
...
@@ -320,14 +330,15 @@ function getChild(el, childNum, options) {
}
/**
* Gets the last child
in
the el, ignoring ghostEl or invisible elements (clones)
* Gets the last child
matching the selector
the el, ignoring ghostEl or invisible elements (clones)
* @param {HTMLElement} el Parent element
* @param {selector} selector Any other elements that should be ignored
* @return {HTMLElement} The last child, ignoring ghostEl
*/
function
lastChild
(
el
,
selector
)
{
let
last
=
el
.
lastElementChild
;
// No point in traversing recursively if only matching immediate children
let
immediateChildrenOnly
=
selector
.
substring
(
1
)
===
'
>
'
;
while
(
last
&&
(
...
...
@@ -552,5 +563,6 @@ export {
clone
,
setRect
,
unsetRect
,
expando
};
expando
,
getParentSortable
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录