@get-set/gs-sortable 0.0.19 → 0.0.21

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,117 +1,102 @@
1
- import { getOffsetFromWindow, getTranslateCoord } from "./general";
2
- import checkItemInContainer from "./checkItemInContainer";
3
- import calculate from "./calculate";
4
- import constParams from "../constants/constParams";
5
- import calculateOnSort from "./calculateOnSort";
6
-
7
- const initMouseMove = (event) => {
8
- const info = window.GSSortableConfigue.draggableInfo;
9
-
10
- if (info != undefined) {
11
- info.moved = true;
12
- const allRefs = [window.GSSortableConfigue.takeFrom];
13
- window.GSSortableConfigue.references.map((item) => {
14
- if (
15
- item.ref.currentParams.acceptFrom.includes(
16
- window.GSSortableConfigue.takeFrom.currentParams.reference
17
- )
18
- ) {
19
- allRefs.push(item.ref);
20
- }
21
- });
22
- let findedRef = "";
23
- allRefs.map((item) => {
24
- if (checkItemInContainer(item.grid, info.$el)) {
25
- findedRef = item.currentParams.reference;
26
- }
27
- });
28
- if (findedRef !== "") {
29
- const newRef = window.GSSortableConfigue.instance(findedRef);
30
- if (
31
- newRef != undefined &&
32
- info.ref.currentParams.reference !== newRef.currentParams.reference
33
- ) {
34
- if (document.querySelector(".gs-sortable-placeholder") != null) {
35
- document.querySelector(".gs-sortable-placeholder").remove();
36
- calculate(window.GSSortableConfigue.overInItemRef);
37
- }
38
- window.GSSortableConfigue.overInItemRef = newRef;
39
- info.$el.style.width =
40
- window.GSSortableConfigue.overInItemRef.itemWidth;
41
- const newWidth = info.$el.clientWidth;
42
- const newHeight = info.$el.clientHeight;
43
-
44
- const newContainerOffset = getOffsetFromWindow(
45
- window.GSSortableConfigue.takeFrom.grid
46
- );
47
-
48
- const translateY =
49
- event.clientY - newContainerOffset.top - newHeight * info.fromTop;
50
- const translateX =
51
- event.clientX - newContainerOffset.left - newWidth * info.fromLeft;
52
-
53
- const elStyles = getComputedStyle(info.$el);
54
- const top = parseFloat(elStyles.top);
55
- const left = parseFloat(elStyles.left);
56
- if (!window.GSSortableConfigue.overInItemRef.currentParams.takeClone) {
57
- const placeholder = document.createElement("div");
58
- placeholder.classList.add("gs-sortable-placeholder");
59
- placeholder.style.position = elStyles.position;
60
- info.$el.style.transform = `translate(${translateX}px, ${translateY}px)`;
61
- placeholder.style.transition = `left ${constParams.animateionSpeed}ms, top ${constParams.animateionSpeed}ms, transform ${constParams.animateionSpeed}ms, opacity ${constParams.animateionSpeed}ms, opacity ${constParams.animateionSpeed}ms`;
62
-
63
- placeholder.style.top = `${top}px`;
64
- placeholder.style.left = `${left}px`;
65
- placeholder.style.border = elStyles.border;
66
- placeholder.style.borderRadius = elStyles.borderRadius;
67
- info.placeholder = placeholder;
68
- info.ref = newRef;
69
- placeholder.style.width = `${info.$el.offsetWidth}px`;
70
- placeholder.style.height = `${info.$el.offsetHeight}px`;
71
- newRef.grid.append(placeholder);
72
- calculate(newRef);
73
- return;
74
- } else {
75
- info.ref = newRef;
76
- }
77
- }
78
- }
79
- const params = info.ref.currentParams;
80
- const clientX = event.clientX;
81
- const clientY = event.clientY;
82
- const $el = info.$el;
83
- const containerStyles = getComputedStyle(info.ref.grid);
84
- const paddingLeft = parseFloat(containerStyles.paddingLeft);
85
- const paddingTop = parseFloat(containerStyles.paddingTop);
86
- const paddingRight = parseFloat(containerStyles.paddingRight);
87
- const paddingBottom = parseFloat(containerStyles.paddingBottom);
88
- const containerInnerHeight =
89
- info.ref.grid.clientHeight - paddingTop - paddingBottom;
90
- const containerInnerWidth =
91
- info.ref.grid.clientWidth - paddingLeft - paddingRight;
92
- const moveX = clientX - info.clientX;
93
- const moveY = clientY - info.clientY;
94
- const coord = getTranslateCoord($el);
95
- info.clientX = clientX;
96
- info.clientY = clientY;
97
- let tranlateX = moveX + coord.x;
98
- let tranlateY = moveY + coord.y;
99
- if (!params.allowOutOfBox) {
100
- const minY = 0;
101
- const minX = 0;
102
- const maxY = containerInnerHeight - $el.offsetHeight;
103
- const maxX = containerInnerWidth - $el.offsetWidth;
104
- tranlateX = Math.min(Math.max(tranlateX, minX), maxX);
105
- tranlateY = Math.min(Math.max(tranlateY, minY), maxY);
106
- }
107
- $el.style.transform = `translate(${tranlateX}px, ${tranlateY}px)`;
108
-
109
- if (findedRef != "") {
110
- calculateOnSort(window.GSSortableConfigue.overInItemRef);
111
- }
112
- }
113
- window.scrollY = document.documentElement.scrollTop;
114
- window.scrollX = document.documentElement.scrollLeft;
115
- };
116
-
117
- export default initMouseMove;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _general = require("./general");
8
+ var _checkItemInContainer = _interopRequireDefault(require("./checkItemInContainer"));
9
+ var _calculate = _interopRequireDefault(require("./calculate"));
10
+ var _constParams = _interopRequireDefault(require("../constants/constParams"));
11
+ var _calculateOnSort = _interopRequireDefault(require("./calculateOnSort"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
+ var initMouseMove = function initMouseMove(event) {
14
+ var info = window.GSSortableConfigue.draggableInfo;
15
+ if (info != undefined) {
16
+ info.moved = true;
17
+ var allRefs = [window.GSSortableConfigue.takeFrom];
18
+ window.GSSortableConfigue.references.map(function (item) {
19
+ if (item.ref.currentParams.acceptFrom.includes(window.GSSortableConfigue.takeFrom.currentParams.reference)) {
20
+ allRefs.push(item.ref);
21
+ }
22
+ });
23
+ var findedRef = "";
24
+ allRefs.map(function (item) {
25
+ if ((0, _checkItemInContainer["default"])(item.grid, info.$el)) {
26
+ findedRef = item.currentParams.reference;
27
+ }
28
+ });
29
+ if (findedRef !== "") {
30
+ var newRef = window.GSSortableConfigue.instance(findedRef);
31
+ if (newRef != undefined && info.ref.currentParams.reference !== newRef.currentParams.reference) {
32
+ if (document.querySelector(".gs-sortable-placeholder") != null) {
33
+ document.querySelector(".gs-sortable-placeholder").remove();
34
+ (0, _calculate["default"])(window.GSSortableConfigue.overInItemRef);
35
+ }
36
+ window.GSSortableConfigue.overInItemRef = newRef;
37
+ info.$el.style.width = window.GSSortableConfigue.overInItemRef.itemWidth;
38
+ var newWidth = info.$el.clientWidth;
39
+ var newHeight = info.$el.clientHeight;
40
+ var newContainerOffset = (0, _general.getOffsetFromWindow)(window.GSSortableConfigue.takeFrom.grid);
41
+ var translateY = event.clientY - newContainerOffset.top - newHeight * info.fromTop;
42
+ var translateX = event.clientX - newContainerOffset.left - newWidth * info.fromLeft;
43
+ var elStyles = getComputedStyle(info.$el);
44
+ var top = parseFloat(elStyles.top);
45
+ var left = parseFloat(elStyles.left);
46
+ if (!window.GSSortableConfigue.overInItemRef.currentParams.takeClone) {
47
+ var placeholder = document.createElement("div");
48
+ placeholder.classList.add("gs-sortable-placeholder");
49
+ placeholder.style.position = elStyles.position;
50
+ info.$el.style.transform = "translate(".concat(translateX, "px, ").concat(translateY, "px)");
51
+ placeholder.style.transition = "left ".concat(_constParams["default"].animateionSpeed, "ms, top ").concat(_constParams["default"].animateionSpeed, "ms, transform ").concat(_constParams["default"].animateionSpeed, "ms, opacity ").concat(_constParams["default"].animateionSpeed, "ms, opacity ").concat(_constParams["default"].animateionSpeed, "ms");
52
+ placeholder.style.top = "".concat(top, "px");
53
+ placeholder.style.left = "".concat(left, "px");
54
+ placeholder.style.border = elStyles.border;
55
+ placeholder.style.borderRadius = elStyles.borderRadius;
56
+ info.placeholder = placeholder;
57
+ info.ref = newRef;
58
+ placeholder.style.width = "".concat(info.$el.offsetWidth, "px");
59
+ placeholder.style.height = "".concat(info.$el.offsetHeight, "px");
60
+ newRef.grid.append(placeholder);
61
+ (0, _calculate["default"])(newRef);
62
+ return;
63
+ } else {
64
+ info.ref = newRef;
65
+ }
66
+ }
67
+ }
68
+ var params = info.ref.currentParams;
69
+ var clientX = event.clientX;
70
+ var clientY = event.clientY;
71
+ var $el = info.$el;
72
+ var containerStyles = getComputedStyle(info.ref.grid);
73
+ var paddingLeft = parseFloat(containerStyles.paddingLeft);
74
+ var paddingTop = parseFloat(containerStyles.paddingTop);
75
+ var paddingRight = parseFloat(containerStyles.paddingRight);
76
+ var paddingBottom = parseFloat(containerStyles.paddingBottom);
77
+ var containerInnerHeight = info.ref.grid.clientHeight - paddingTop - paddingBottom;
78
+ var containerInnerWidth = info.ref.grid.clientWidth - paddingLeft - paddingRight;
79
+ var moveX = clientX - info.clientX;
80
+ var moveY = clientY - info.clientY;
81
+ var coord = (0, _general.getTranslateCoord)($el);
82
+ info.clientX = clientX;
83
+ info.clientY = clientY;
84
+ var tranlateX = moveX + coord.x;
85
+ var tranlateY = moveY + coord.y;
86
+ if (!params.allowOutOfBox) {
87
+ var minY = 0;
88
+ var minX = 0;
89
+ var maxY = containerInnerHeight - $el.offsetHeight;
90
+ var maxX = containerInnerWidth - $el.offsetWidth;
91
+ tranlateX = Math.min(Math.max(tranlateX, minX), maxX);
92
+ tranlateY = Math.min(Math.max(tranlateY, minY), maxY);
93
+ }
94
+ $el.style.transform = "translate(".concat(tranlateX, "px, ").concat(tranlateY, "px)");
95
+ if (findedRef != "") {
96
+ (0, _calculateOnSort["default"])(window.GSSortableConfigue.overInItemRef);
97
+ }
98
+ }
99
+ window.scrollY = document.documentElement.scrollTop;
100
+ window.scrollX = document.documentElement.scrollLeft;
101
+ };
102
+ var _default = exports["default"] = initMouseMove;
@@ -1,23 +1,26 @@
1
- import { getTranslateCoord } from './general';
2
-
3
- const initScroll = () => {
4
- const info = window.GSSortableConfigue.draggableInfo;
5
-
6
- if (info != undefined) {
7
- const $el = info.$el;
8
- const coord = getTranslateCoord(info.$el);
9
- let translateX = coord.x;
10
- let translateY = coord.y;
11
- const scrollY = document.documentElement.scrollTop;
12
- const scrollX = document.documentElement.scrollLeft;
13
- const scrollYDist = scrollY - window.scrollY;
14
- const scrollXDist = scrollX - window.scrollX;
15
- translateX = translateX + scrollXDist;
16
- translateY = translateY + scrollYDist;
17
- window.scrollY = scrollY;
18
- window.scrollX = scrollX;
19
- info.$el.style.transform = `translate(${translateX}px, ${translateY}px)`;
20
- }
21
- };
22
-
23
- export default initScroll;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _general = require("./general");
8
+ var initScroll = function initScroll() {
9
+ var info = window.GSSortableConfigue.draggableInfo;
10
+ if (info != undefined) {
11
+ var $el = info.$el;
12
+ var coord = (0, _general.getTranslateCoord)(info.$el);
13
+ var translateX = coord.x;
14
+ var translateY = coord.y;
15
+ var scrollY = document.documentElement.scrollTop;
16
+ var scrollX = document.documentElement.scrollLeft;
17
+ var scrollYDist = scrollY - window.scrollY;
18
+ var scrollXDist = scrollX - window.scrollX;
19
+ translateX = translateX + scrollXDist;
20
+ translateY = translateY + scrollYDist;
21
+ window.scrollY = scrollY;
22
+ window.scrollX = scrollX;
23
+ info.$el.style.transform = "translate(".concat(translateX, "px, ").concat(translateY, "px)");
24
+ }
25
+ };
26
+ var _default = exports["default"] = initScroll;
@@ -1,84 +1,73 @@
1
- import constParams from "../constants/constParams";
2
- import calculate from "./calculate";
3
- import { getOffsetFromBody, moveChildToIndex } from "./general";
4
-
5
- const initSortEnd = (event) => {
6
- const info = { ...window.GSSortableConfigue.draggableInfo };
7
- if (window.GSSortableConfigue.draggableInfo != undefined) {
8
- if (info.moved) {
9
- let containerDifX = 0;
10
- let containerDifY = 0;
11
- if (
12
- info.ref.currentParams.reference !==
13
- window.GSSortableConfigue.takeFrom.currentParams.reference
14
- ) {
15
- const fromCoord = getOffsetFromBody(
16
- window.GSSortableConfigue.takeFrom.grid
17
- );
18
- const toCoord = getOffsetFromBody(info.ref.grid);
19
- containerDifY = toCoord.top - fromCoord.top;
20
- containerDifX = toCoord.left - fromCoord.left;
21
- }
22
- info.ref.isAddjusting = true;
23
- const $el = info.$el;
24
- const placeholder = info.placeholder;
25
- info.$el.classList.remove("gs-sortable-item-inmove");
26
- info.ref.grid.classList.remove("gs-sortable-active");
27
- if (info.ref.grid.closest(".gs-sortable-item-active-parent") != null) {
28
- info.ref.grid
29
- .closest(".gs-sortable-item-active-parent")
30
- .classList.remove("gs-sortable-item-active-parent");
31
- }
32
- info.$el.classList.add("gs-sortable-item-addjusting");
33
- window.GSSortableConfigue.draggableInfo = undefined;
34
- info.$el.style.top = `${info.newTop + containerDifY}px`;
35
- info.$el.style.left = `${info.newLeft + containerDifX}px`;
36
- info.$el.style.removeProperty("transform");
37
- setTimeout(() => {
38
- $el.classList.remove("gs-sortable-item-addjusting");
39
- if (
40
- info.ref.currentParams.reference ===
41
- window.GSSortableConfigue.takeFrom.currentParams.reference &&
42
- window.GSSortableConfigue.takeFrom.currentParams.takeClone
43
- ) {
44
- info.$el.remove();
45
- } else {
46
- if (info.index != undefined) {
47
- moveChildToIndex(info.ref.grid, info.$el, info.index);
48
- }
49
- }
50
- placeholder.remove();
51
- if (
52
- info.ref.currentParams.reference !==
53
- window.GSSortableConfigue.takeFrom.currentParams.reference
54
- ) {
55
- window.GSSortableConfigue.takeFrom.currentParams.afterSort(
56
- window.GSSortableConfigue.takeFrom.grid.querySelectorAll(
57
- ".gs-sortable-item"
58
- )
59
- );
60
- info.ref.currentParams.afterSort(
61
- info.ref.grid.querySelectorAll(".gs-sortable-item")
62
- );
63
- window.GSSortableConfigue.takeFrom.refresh();
64
- info.ref.refresh();
65
- } else {
66
- calculate(info.ref);
67
- info.ref.currentParams.afterSort(
68
- info.ref.grid.querySelectorAll(".gs-sortable-item")
69
- );
70
- }
71
- info.ref.isAddjusting = false;
72
- }, constParams.animateionSpeed);
73
- } else {
74
- const placeholder = info.placeholder;
75
- info.$el.style.top = `${info.newTop}px`;
76
- info.$el.style.left = `${info.newLeft}px`;
77
- info.$el.style.removeProperty("transform");
78
- placeholder.remove();
79
- window.GSSortableConfigue.draggableInfo = undefined;
80
- }
81
- }
82
- };
83
-
84
- export default initSortEnd;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _constParams = _interopRequireDefault(require("../constants/constParams"));
8
+ var _calculate = _interopRequireDefault(require("./calculate"));
9
+ var _general = require("./general");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ var initSortEnd = function initSortEnd(event) {
18
+ var info = _objectSpread({}, window.GSSortableConfigue.draggableInfo);
19
+ if (window.GSSortableConfigue.draggableInfo != undefined) {
20
+ if (info.moved) {
21
+ var containerDifX = 0;
22
+ var containerDifY = 0;
23
+ if (info.ref.currentParams.reference !== window.GSSortableConfigue.takeFrom.currentParams.reference) {
24
+ var fromCoord = (0, _general.getOffsetFromBody)(window.GSSortableConfigue.takeFrom.grid);
25
+ var toCoord = (0, _general.getOffsetFromBody)(info.ref.grid);
26
+ containerDifY = toCoord.top - fromCoord.top;
27
+ containerDifX = toCoord.left - fromCoord.left;
28
+ }
29
+ info.ref.isAddjusting = true;
30
+ var $el = info.$el;
31
+ var placeholder = info.placeholder;
32
+ info.$el.classList.remove("gs-sortable-item-inmove");
33
+ info.ref.grid.classList.remove("gs-sortable-active");
34
+ if (info.ref.grid.closest(".gs-sortable-item-active-parent") != null) {
35
+ info.ref.grid.closest(".gs-sortable-item-active-parent").classList.remove("gs-sortable-item-active-parent");
36
+ }
37
+ info.$el.classList.add("gs-sortable-item-addjusting");
38
+ window.GSSortableConfigue.draggableInfo = undefined;
39
+ info.$el.style.top = "".concat(info.newTop + containerDifY, "px");
40
+ info.$el.style.left = "".concat(info.newLeft + containerDifX, "px");
41
+ info.$el.style.removeProperty("transform");
42
+ setTimeout(function () {
43
+ $el.classList.remove("gs-sortable-item-addjusting");
44
+ if (info.ref.currentParams.reference === window.GSSortableConfigue.takeFrom.currentParams.reference && window.GSSortableConfigue.takeFrom.currentParams.takeClone) {
45
+ info.$el.remove();
46
+ } else {
47
+ if (info.index != undefined) {
48
+ (0, _general.moveChildToIndex)(info.ref.grid, info.$el, info.index);
49
+ }
50
+ }
51
+ placeholder.remove();
52
+ if (info.ref.currentParams.reference !== window.GSSortableConfigue.takeFrom.currentParams.reference) {
53
+ window.GSSortableConfigue.takeFrom.currentParams.afterSort(window.GSSortableConfigue.takeFrom.grid.querySelectorAll(".gs-sortable-item"));
54
+ info.ref.currentParams.afterSort(info.ref.grid.querySelectorAll(".gs-sortable-item"));
55
+ window.GSSortableConfigue.takeFrom.refresh();
56
+ info.ref.refresh();
57
+ } else {
58
+ (0, _calculate["default"])(info.ref);
59
+ info.ref.currentParams.afterSort(info.ref.grid.querySelectorAll(".gs-sortable-item"));
60
+ }
61
+ info.ref.isAddjusting = false;
62
+ }, _constParams["default"].animateionSpeed);
63
+ } else {
64
+ var _placeholder = info.placeholder;
65
+ info.$el.style.top = "".concat(info.newTop, "px");
66
+ info.$el.style.left = "".concat(info.newLeft, "px");
67
+ info.$el.style.removeProperty("transform");
68
+ _placeholder.remove();
69
+ window.GSSortableConfigue.draggableInfo = undefined;
70
+ }
71
+ }
72
+ };
73
+ var _default = exports["default"] = initSortEnd;