cypress-dragndrop-kit 1.0.8 → 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/README.md +3 -3
- 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/README.md
CHANGED
@@ -74,10 +74,10 @@ it('should be able to drag and drop an item by using "dragAndDrop()"', () => {
|
|
74
74
|
|
75
75
|
// Usage of "dragTo(target, { pressDelay })"
|
76
76
|
it('should be able to drag and drop an item after a 2 second delay by using "dragTo()"', () => {
|
77
|
-
|
77
|
+
cy.get('[data-id="47"]').dragTo('[data-id="3"]', { pressDelay: 2000 });
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
cy.get('[data-id="47"]').should('have.attr', 'data-index', 3);
|
80
|
+
cy.get('[data-id="3"]').should('have.attr', 'data-index', 4);
|
81
81
|
})
|
82
82
|
```
|
83
83
|
|
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;
|