Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uxpin/html-dnd

Package Overview
Dependencies
Maintainers
31
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uxpin/html-dnd - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

2

package.json
{
"name": "@uxpin/html-dnd",
"version": "2.1.0",
"version": "2.2.0",
"description": "HTML Drag and Drop Simulator for E2E testing",

@@ -5,0 +5,0 @@ "keywords": [

@@ -7,6 +7,7 @@ namespace dnd {

dropOffset?: Array<number>;
middleStepOffset?: Array<number>;
}
export function simulate(draggable: Element, droppable: Element, dndSimulateConfig: DndSimulateConfig, middleStep?:Element): void {
const {dragX, dragY, dropX, dropY} = calculateMousePositions(draggable, droppable, dndSimulateConfig);
export function simulate(draggable: Element, droppable: Element, dndSimulateConfig: DndSimulateConfig, middleStep?: Element): void {
const {dragX, dragY, dropX, dropY, middleStepX, middleStepY} = calculateMousePositions(draggable, droppable, dndSimulateConfig, middleStep);

@@ -28,3 +29,3 @@ const store = new DragDataStore();

if (middleStep) {
const dragOverEventMiddleStep = createEventWithDataTransfer("dragover", dataTransfer, 0, 0, 0, dropX, dropY, false, false, false, false, 0, null);
const dragOverEventMiddleStep = createEventWithDataTransfer("dragover", dataTransfer, 0, 0, 0, middleStepX, middleStepY, false, false, false, false, 0, null);
middleStep.dispatchEvent(dragOverEventMiddleStep);

@@ -54,2 +55,4 @@ }

dropY: number;
middleStepX?: number;
middleStepY?: number;
}

@@ -60,3 +63,3 @@

*/
function calculateMousePositions(draggable: Element, droppable: Element, dndSimulateConfig: DndSimulateConfig): MousePositions {
function calculateMousePositions(draggable: Element, droppable: Element, dndSimulateConfig: DndSimulateConfig, middleStep?: Element): MousePositions {
const dragElementPosition = draggable.getBoundingClientRect();

@@ -89,3 +92,20 @@ const dropElementPosition = droppable.getBoundingClientRect();

return {dragX, dragY, dropX, dropY};
if (middleStep) {
let middleStepElementPosition = middleStep.getBoundingClientRect();
let middleStepX = middleStepElementPosition.left;
let middleStepY = middleStepElementPosition.top;
if (dndSimulateConfig && dndSimulateConfig.middleStepOffset) {
middleStepX += dndSimulateConfig.middleStepOffset[0];
middleStepY += dndSimulateConfig.middleStepOffset[1];
}
else {
middleStepX += (middleStepElementPosition.width / 2);
middleStepY += (middleStepElementPosition.height / 2);
}
return { dragX, dragY, dropX, dropY, middleStepX, middleStepY };
}
return { dragX, dragY, dropX, dropY };
}

@@ -92,0 +112,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc