cypress-dragndrop-kit 1.0.9 → 1.0.10
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.
- package/dist/index.js +2 -6
- package/dist/utils.d.ts +11 -0
- package/dist/utils.js +7 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -15,12 +15,8 @@ Cypress.Commands.add("dragTo", { prevSubject: 'element' }, (sourceElement, targe
|
|
15
15
|
cy.get(targetElement).first().scrollIntoView();
|
16
16
|
}
|
17
17
|
else {
|
18
|
-
|
19
|
-
|
20
|
-
sourceCoordinates = Object.assign(Object.assign({}, sourceCoordinates), { x: startX, y: startY });
|
21
|
-
const endX = targetCoordinates.left + targetCoordinates.width / 2;
|
22
|
-
const endY = targetCoordinates.top + targetCoordinates.height / 2;
|
23
|
-
targetCoordinates = Object.assign(Object.assign({}, targetCoordinates), { x: endX, y: endY });
|
18
|
+
sourceCoordinates = (0, utils_1.calculateCoordinates)(sourceCoordinates);
|
19
|
+
targetCoordinates = (0, utils_1.calculateCoordinates)(targetCoordinates);
|
24
20
|
}
|
25
21
|
cy.wrap(source)
|
26
22
|
.trigger("mousedown", (0, utils_1.params)(sourceCoordinates))
|
package/dist/utils.d.ts
CHANGED
@@ -11,3 +11,14 @@ export declare const params: ({ x, y }: Coordinate, offset?: number) => {
|
|
11
11
|
clientY: number;
|
12
12
|
force: boolean;
|
13
13
|
};
|
14
|
+
export declare const calculateCoordinates: (coordinates: DOMRect) => {
|
15
|
+
x: number;
|
16
|
+
y: number;
|
17
|
+
height: number;
|
18
|
+
width: number;
|
19
|
+
bottom: number;
|
20
|
+
left: number;
|
21
|
+
right: number;
|
22
|
+
top: number;
|
23
|
+
toJSON(): any;
|
24
|
+
};
|
package/dist/utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.params = void 0;
|
3
|
+
exports.calculateCoordinates = exports.params = void 0;
|
4
4
|
const params = ({ x, y }, offset = 0) => ({
|
5
5
|
button: 0,
|
6
6
|
clientX: x + offset,
|
@@ -8,3 +8,9 @@ const params = ({ x, y }, offset = 0) => ({
|
|
8
8
|
force: true,
|
9
9
|
});
|
10
10
|
exports.params = params;
|
11
|
+
const calculateCoordinates = (coordinates) => {
|
12
|
+
const x = coordinates.left + coordinates.width / 2;
|
13
|
+
const y = coordinates.top + coordinates.height / 2;
|
14
|
+
return Object.assign(Object.assign({}, coordinates), { x, y });
|
15
|
+
};
|
16
|
+
exports.calculateCoordinates = calculateCoordinates;
|