Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
leizi929
Sortable
提交
aee4b91b
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 搜索 >>
提交
aee4b91b
编写于
7月 10, 2019
作者:
O
owen-m1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
polish
上级
e9939155
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
17 addition
and
50 deletion
+17
-50
.circleci/config.yml
.circleci/config.yml
+0
-4
CONTRIBUTING.md
CONTRIBUTING.md
+0
-4
README.md
README.md
+8
-1
Sortable.js
Sortable.js
+3
-13
plugins/AutoScroll/AutoScroll.js
plugins/AutoScroll/AutoScroll.js
+5
-3
scripts/test-compat.js
scripts/test-compat.js
+1
-0
tests/helpers.js
tests/helpers.js
+0
-25
未找到文件。
.circleci/config.yml
浏览文件 @
aee4b91b
...
...
@@ -20,10 +20,6 @@ jobs:
-
run
:
npm run build:umd
-
store_artifacts
:
path
:
./Sortable.js
-
run
:
npm run test:compat
-
run
:
npm run test
...
...
CONTRIBUTING.md
浏览文件 @
aee4b91b
...
...
@@ -19,10 +19,6 @@
2.
Clone locally
3.
Run
`npm i`
in the local repo
### Testing
-
To run the e2e tests in Chrome, use
`npm run test`
-
Tests will be run automatically in continuous integration before your PR is merged
### Building
-
For development, build the
`./Sortable.js`
file using the command
`npm run build:umd:watch`
...
...
README.md
浏览文件 @
aee4b91b
...
...
@@ -694,7 +694,14 @@ The clone element.
---
##### Sortable.mount(plugin:`...SortablePlugin|...SortablePlugin[]`)
##### Sortable.get(element:`HTMLElement`):`Sortable`
Get the Sortable instance on an element.
---
##### Sortable.mount(plugin:`...SortablePlugin|SortablePlugin[]`)
Mounts a plugin to Sortable.
...
...
Sortable.js
浏览文件 @
aee4b91b
...
...
@@ -1032,7 +1032,7 @@
return
elCSS
.
gridTemplateColumns
.
split
(
'
'
).
length
<=
1
?
'
vertical
'
:
'
horizontal
'
;
}
if
(
child1
&&
firstChildCSS
[
"
float
"
]
&&
firstChildCSS
[
"
float
"
]
!==
'
none
'
)
{
if
(
child1
&&
firstChildCSS
[
"
float
"
]
!==
'
none
'
)
{
var
touchingSideChild2
=
firstChildCSS
[
"
float
"
]
===
'
left
'
?
'
left
'
:
'
right
'
;
return
child2
&&
(
secondChildCSS
.
clear
===
'
both
'
||
secondChildCSS
.
clear
===
touchingSideChild2
)
?
'
vertical
'
:
'
horizontal
'
;
}
...
...
@@ -2587,21 +2587,11 @@
detectDirection
:
_detectDirection
,
getChild
:
getChild
};
/**
* Get the Sortable instance of an element
* @param {HTMLElement} element The element
* @return {Sortable|undefined} The instance of Sortable
*/
Sortable
.
get
=
function
(
element
)
{
return
element
[
expando
];
};
/**
* Mount a plugin to Sortable
* @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
*/
Sortable
.
mount
=
function
()
{
for
(
var
_len
=
arguments
.
length
,
plugins
=
new
Array
(
_len
),
_key
=
0
;
_key
<
_len
;
_key
++
)
{
plugins
[
_key
]
=
arguments
[
_key
];
...
...
@@ -2703,8 +2693,8 @@
_handleAutoScroll
:
function
_handleAutoScroll
(
evt
,
fallback
)
{
var
_this
=
this
;
var
x
=
(
evt
.
touches
?
evt
.
touches
[
0
]
:
evt
)
.
clientX
,
y
=
(
evt
.
touches
?
evt
.
touches
[
0
]
:
evt
)
.
clientY
,
var
x
=
evt
.
clientX
,
y
=
evt
.
clientY
,
elem
=
document
.
elementFromPoint
(
x
,
y
);
touchEvt$1
=
evt
;
// IE does not seem to have native autoscroll,
// Edge's autoscroll seems too conditional,
...
...
plugins/AutoScroll/AutoScroll.js
浏览文件 @
aee4b91b
...
...
@@ -164,7 +164,9 @@ function clearPointerElemChangedInterval() {
const
autoScroll
=
throttle
(
function
(
evt
,
options
,
rootEl
,
isFallback
)
{
// Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
if
(
!
options
.
scroll
)
return
;
const
sens
=
options
.
scrollSensitivity
,
const
x
=
(
evt
.
touches
?
evt
.
touches
[
0
]
:
evt
).
clientX
,
y
=
(
evt
.
touches
?
evt
.
touches
[
0
]
:
evt
).
clientY
,
sens
=
options
.
scrollSensitivity
,
speed
=
options
.
scrollSpeed
,
winScroller
=
getWindowScrollingElement
();
...
...
@@ -220,8 +222,8 @@ const autoScroll = throttle(function(evt, options, rootEl, isFallback) {
canScrollY
=
height
<
scrollHeight
&&
(
elCSS
.
overflowY
===
'
auto
'
||
elCSS
.
overflowY
===
'
scroll
'
);
}
let
vx
=
canScrollX
&&
(
Math
.
abs
(
right
-
evt
.
clientX
)
<=
sens
&&
(
scrollPosX
+
width
)
<
scrollWidth
)
-
(
Math
.
abs
(
left
-
evt
.
clientX
)
<=
sens
&&
!!
scrollPosX
);
let
vy
=
canScrollY
&&
(
Math
.
abs
(
bottom
-
evt
.
clientY
)
<=
sens
&&
(
scrollPosY
+
height
)
<
scrollHeight
)
-
(
Math
.
abs
(
top
-
evt
.
clientY
)
<=
sens
&&
!!
scrollPosY
);
let
vx
=
canScrollX
&&
(
Math
.
abs
(
right
-
x
)
<=
sens
&&
(
scrollPosX
+
width
)
<
scrollWidth
)
-
(
Math
.
abs
(
left
-
x
)
<=
sens
&&
!!
scrollPosX
);
let
vy
=
canScrollY
&&
(
Math
.
abs
(
bottom
-
y
)
<=
sens
&&
(
scrollPosY
+
height
)
<
scrollHeight
)
-
(
Math
.
abs
(
top
-
y
)
<=
sens
&&
!!
scrollPosY
);
if
(
!
autoScrolls
[
layersOut
])
{
...
...
scripts/test-compat.js
浏览文件 @
aee4b91b
...
...
@@ -9,6 +9,7 @@ const browsers = [
'
chrome:headless
'
,
'
firefox:headless
'
];
let
testcafe
;
let
runner
;
let
failedCount
;
...
...
tests/helpers.js
已删除
100644 → 0
浏览文件 @
e9939155
export
async
function
testSorting
(
t
,
dragIndex
,
targetIndex
,
from
,
to
,
offset
=
25
,
expectChange
=
true
)
{
let
targetIndexChange
;
if
(
from
===
to
)
{
targetIndexChange
=
dragIndex
<
targetIndex
?
-
1
:
1
;
}
else
{
targetIndexChange
=
offset
<
25
?
1
:
0
;
}
let
dragStartPosition
=
from
.
child
(
dragIndex
);
let
dragEl
=
await
dragStartPosition
();
let
dragEndPosition
=
to
.
child
(
targetIndex
+
(
targetIndexChange
===
0
&&
1
||
0
));
let
targetStartPosition
=
to
.
child
(
targetIndex
);
let
target
=
await
dragEndPosition
();
let
targetEndPosition
=
to
.
child
(
targetIndex
+
targetIndexChange
);
await
t
.
expect
(
dragStartPosition
.
innerText
).
eql
(
dragEl
.
innerText
)
.
expect
(
targetStartPosition
.
innerText
).
eql
(
target
.
innerText
)
// If in another list: Drag only to the top of the element,
// so that it is inserted at it's position (because of invert)
.
dragToElement
(
dragEl
,
target
,
{
destinationOffsetY
:
offset
})
.
expect
(
expectChange
?
dragEndPosition
.
innerText
:
dragStartPosition
.
innerText
).
eql
(
dragEl
.
innerText
)
.
expect
(
expectChange
?
targetEndPosition
.
innerText
:
targetStartPosition
.
innerText
).
eql
(
target
.
innerText
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录