提交 aee4b91b 编写于 作者: O owen-m1

polish

上级 e9939155
......@@ -20,10 +20,6 @@ jobs:
- run: npm run build:umd
- store_artifacts:
path: ./Sortable.js
- run: npm run test:compat
- run: npm run test
......
......@@ -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`
......
......@@ -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.
......
......@@ -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,
......
......@@ -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]) {
......
......@@ -9,6 +9,7 @@ const browsers = [
'chrome:headless',
'firefox:headless'
];
let testcafe;
let runner;
let failedCount;
......
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.
先完成此消息的编辑!
想要评论请 注册