Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
leizi929
Sortable
提交
d5f598db
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,体验更适合开发者的 AI 搜索 >>
提交
d5f598db
编写于
9月 01, 2016
作者:
L
Lebedev Konstantin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
+ tryInsertOrAppendChild
上级
887fe9d4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
13 deletion
+35
-13
Sortable.js
Sortable.js
+35
-13
未找到文件。
Sortable.js
浏览文件 @
d5f598db
...
...
@@ -518,7 +518,7 @@
_css
(
ghostEl
,
'
zIndex
'
,
'
100000
'
);
_css
(
ghostEl
,
'
pointerEvents
'
,
'
none
'
);
options
.
fallbackOnBody
&&
document
.
body
.
appendChild
(
ghostEl
)
||
rootEl
.
appendChild
(
ghostEl
);
options
.
fallbackOnBody
&&
_insertChild
(
document
.
body
,
ghostEl
)
||
_insertChild
(
rootEl
,
ghostEl
);
// Fixing dimensions.
ghostRect
=
ghostEl
.
getBoundingClientRect
();
...
...
@@ -536,7 +536,7 @@
if
(
activeGroup
.
pull
==
'
clone
'
)
{
cloneEl
=
dragEl
.
cloneNode
(
true
);
_css
(
cloneEl
,
'
display
'
,
'
none
'
);
rootEl
.
insertBefore
(
cloneEl
,
dragEl
);
_insertChild
(
rootEl
,
cloneEl
,
dragEl
);
}
if
(
useFallback
)
{
...
...
@@ -607,10 +607,10 @@
_cloneHide
(
true
);
if
(
cloneEl
||
nextEl
)
{
rootEl
.
insertBefore
(
dragEl
,
cloneEl
||
nextEl
);
_tryInsertOrAppendChild
(
rootEl
,
dragEl
,
cloneEl
||
nextEl
);
}
else
if
(
!
canSort
)
{
rootEl
.
appendChild
(
dragEl
);
_insertChild
(
rootEl
,
dragEl
);
}
return
;
...
...
@@ -633,7 +633,7 @@
if
(
_onMove
(
rootEl
,
el
,
dragEl
,
dragRect
,
target
,
targetRect
)
!==
false
)
{
if
(
!
dragEl
.
contains
(
el
))
{
el
.
appendChild
(
dragEl
);
_insertChild
(
el
,
dragEl
);
parentEl
=
el
;
// actualization
}
...
...
@@ -686,9 +686,13 @@
if
(
!
dragEl
.
contains
(
el
))
{
if
(
after
&&
!
nextSibling
)
{
el
.
appendChild
(
dragEl
);
_insertChild
(
el
,
dragEl
);
}
else
{
target
.
parentNode
.
insertBefore
(
dragEl
,
after
?
nextSibling
:
target
);
_tryInsertOrAppendChild
(
target
.
parentNode
,
dragEl
,
after
?
nextSibling
:
target
);
}
}
...
...
@@ -760,7 +764,7 @@
!
options
.
dropBubble
&&
evt
.
stopPropagation
();
}
ghostEl
&&
ghostEl
.
parentNode
.
removeChild
(
ghostEl
);
ghostEl
&&
_removeChild
(
ghostEl
.
parentNode
,
ghostEl
);
if
(
dragEl
)
{
if
(
this
.
nativeDraggable
)
{
...
...
@@ -790,7 +794,7 @@
}
else
{
// Remove clone
cloneEl
&&
cloneEl
.
parentNode
.
removeChild
(
cloneEl
);
cloneEl
&&
_removeChild
(
cloneEl
.
parentNode
,
cloneEl
);
if
(
dragEl
.
nextSibling
!==
nextEl
)
{
// Get the index of the dragged element within its parent
...
...
@@ -903,8 +907,8 @@
order
.
forEach
(
function
(
id
)
{
if
(
items
[
id
])
{
rootEl
.
removeChild
(
items
[
id
]);
rootEl
.
appendChild
(
items
[
id
]);
_removeChild
(
rootEl
,
items
[
id
]);
_insertChild
(
rootEl
,
items
[
id
]);
}
});
},
...
...
@@ -984,7 +988,7 @@
function
_cloneHide
(
state
)
{
if
(
cloneEl
&&
(
cloneEl
.
state
!==
state
))
{
_css
(
cloneEl
,
'
display
'
,
state
?
'
none
'
:
''
);
!
state
&&
cloneEl
.
state
&&
rootEl
.
insertBefore
(
cloneEl
,
dragEl
);
!
state
&&
cloneEl
.
state
&&
_insertChild
(
rootEl
,
cloneEl
,
dragEl
);
cloneEl
.
state
=
state
;
}
}
...
...
@@ -1244,6 +1248,21 @@
return
dst
;
}
function
_insertChild
(
parent
,
newNode
,
refNode
)
{
parent
.
insertBefore
(
newNode
,
refNode
);
}
function
_tryInsertOrAppendChild
(
parent
,
newNode
,
refNode
)
{
try
{
parent
.
insertBefore
(
newNode
,
refNode
);
}
catch
(
err
)
{
_insertChild
(
parent
,
newNode
);
}
}
function
_removeChild
(
parent
,
node
)
{
parent
.
removeChild
(
parent
,
node
);
}
// Export utils
Sortable
.
utils
=
{
...
...
@@ -1258,7 +1277,10 @@
throttle
:
_throttle
,
closest
:
_closest
,
toggleClass
:
_toggleClass
,
index
:
_index
index
:
_index
,
insertChild
:
_insertChild
,
tryInsertOrAppendChild
:
_tryInsertOrAppendChild
,
removeChild
:
_removeChild
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录