cypress-dragndrop-kit 1.0.9 → 1.0.11

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 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
- const startX = sourceCoordinates.left + sourceCoordinates.width / 2;
19
- const startY = sourceCoordinates.top + sourceCoordinates.height / 2;
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))
@@ -28,7 +24,7 @@ Cypress.Commands.add("dragTo", { prevSubject: 'element' }, (sourceElement, targe
28
24
  .trigger("mousemove", (0, utils_1.params)(sourceCoordinates, 10));
29
25
  cy.get("body")
30
26
  .trigger("mousemove", (0, utils_1.params)(targetCoordinates))
31
- .wait(1000)
27
+ .wait(500)
32
28
  .trigger("mouseup", { force: true });
33
29
  });
34
30
  });
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress-dragndrop-kit",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Custom command meant for interacting with draggable elements in the UI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types.d.ts",