@fr0st/ui-sortable 2.0.5 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,80 +0,0 @@
1
- import $ from '@fr0st/query';
2
-
3
- /**
4
- * Check for window scroll.
5
- */
6
- export function _checkScroll() {
7
- $.hide(this._target);
8
-
9
- const originalX = $.getScrollX(window);
10
- const originalY = $.getScrollY(window);
11
-
12
- let offsetX = originalX;
13
- let offsetY = originalY;
14
-
15
- if (this._pos.y < originalY + this._options.scrollSensitivity) {
16
- offsetY = Math.max(0, originalY - this._options.scrollSpeed);
17
- } else if (this._pos.y > originalY + $.height(window) - this._options.scrollSensitivity) {
18
- const docHeight = $.height(document, { boxSize: $.SCROLL_BOX });
19
- offsetY = Math.min(docHeight, originalY + this._options.scrollSpeed);
20
- }
21
-
22
- if (this._pos.x < originalX + this._options.scrollSensitivity) {
23
- offsetX = Math.max(0, originalX - this._options.scrollSpeed);
24
- } else if (this._pos.x > originalX + $.width(window) - this._options.scrollSensitivity) {
25
- const docWidth = $.width(document, { boxSize: $.SCROLL_BOX });
26
- offsetX = Math.min(docWidth, originalX + this._options.scrollSpeed);
27
- }
28
-
29
- if (offsetX !== originalX || offsetY !== originalY) {
30
- $.setStyle(':root', { scrollBehavior: 'initial' });
31
- $.setScroll(document, offsetX, offsetY);
32
- $.setStyle(':root', { scrollBehavior: '' });
33
-
34
- this._pos.x += offsetX - originalX;
35
- this._pos.y += offsetY - originalY;
36
- }
37
-
38
- $.show(this._target);
39
-
40
- this._checkScrollTimer = setTimeout((_) => {
41
- this._checkScroll();
42
- }, 0);
43
- };
44
-
45
- /**
46
- * Refresh Sortable item cursors.
47
- */
48
- export function _refreshCursors() {
49
- const elements = $.find(this._selector, this._node);
50
-
51
- $.setStyle(elements, { cursor: this._options.cursor });
52
- };
53
-
54
- /**
55
- * Update the target element.
56
- * @param {HTMLElement} nearestItem The current nearest item.
57
- * @param {number} x The mouse X position.
58
- * @param {number} y The mouse Y position.
59
- */
60
- export function _updateTarget(nearestItem, x, y) {
61
- const nearestCenter = $.center(nearestItem, { offset: true });
62
- const targetCenter = $.center(this._target, { offset: true });
63
-
64
- let method;
65
- if (this._options.axis === 'y' || nearestCenter.x === targetCenter.x) {
66
- method = y < nearestCenter.y ?
67
- 'before' :
68
- 'after';
69
- } else if (this._options.axis === 'x' || nearestCenter.y === targetCenter.y) {
70
- method = x < nearestCenter.x ?
71
- 'before' :
72
- 'after';
73
- } else {
74
- method = x < nearestCenter.x && y < nearestCenter.y ?
75
- 'before' :
76
- 'after';
77
- }
78
-
79
- $[method](nearestItem, this._target);
80
- };