Skip to content

Commit

Permalink
chore: removes artifact code copyNodeStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
sashamilenkovic committed Dec 9, 2024
1 parent 358c5e7 commit 30a5bbc
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 114 deletions.
30 changes: 0 additions & 30 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ __export(src_exports, {
addNodeClass: () => addNodeClass,
addParentClass: () => addParentClass,
animations: () => animations,
copyNodeStyle: () => copyNodeStyle,
createEmitter: () => createEmitter,
dragAndDrop: () => dragAndDrop,
dragStateProps: () => dragStateProps,
Expand Down Expand Up @@ -2133,7 +2132,6 @@ function initDrag(data, draggedNodes2) {
const clonedNode = node.el.cloneNode(true);
clonedNode.style.pointerEvents = "none";
clonedNode.id = node.el.id + "-clone";
copyNodeStyle(node.el, clonedNode, true);
wrapper.append(clonedNode);
}
const { width } = draggedNodes2[0].el.getBoundingClientRect();
Expand Down Expand Up @@ -2967,33 +2965,6 @@ function addEvents(el, events) {
}
return abortController;
}
function copyNodeStyle(sourceNode, targetNode, omitKeys = false) {
const computedStyle = window.getComputedStyle(sourceNode);
const omittedKeysSet = /* @__PURE__ */ new Set([
"position",
"z-index",
"top",
"left",
"x",
"pointer-events",
"y",
"transform-origin",
"filter",
"-webkit-text-fill-color"
]);
let styles = "";
for (const key of Array.from(computedStyle)) {
if (omitKeys === false && key && omittedKeysSet.has(key)) continue;
const value = computedStyle.getPropertyValue(key);
const priority = computedStyle.getPropertyPriority(key);
styles += `${key}: ${value}${priority ? " !important" : ""}; `;
}
targetNode.style.cssText += styles;
targetNode.style.pointerEvents = "none";
const sourceChildren = Array.from(sourceNode.children);
const targetChildren = Array.from(targetNode.children);
if (sourceChildren.length === 0 || targetChildren.length === 0) return;
}
function eventCoordinates(data) {
return { x: data.clientX, y: data.clientY };
}
Expand Down Expand Up @@ -3021,7 +2992,6 @@ function getRealCoords2(el) {
addNodeClass,
addParentClass,
animations,
copyNodeStyle,
createEmitter,
dragAndDrop,
dragStateProps,
Expand Down
2 changes: 1 addition & 1 deletion dist/index.cjs.map

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions dist/index.d.cts
Original file line number Diff line number Diff line change
Expand Up @@ -1108,11 +1108,10 @@ declare function isNode(el: unknown): el is Node;
* @returns - The abort controller used for the event listeners.
*/
declare function addEvents(el: Document | ShadowRoot | Node | HTMLElement | Window, events: EventHandlers | any): AbortController;
declare function copyNodeStyle(sourceNode: HTMLElement, targetNode: HTMLElement, omitKeys?: boolean): void;
declare function eventCoordinates(data: DragEvent | PointerEvent): {
x: number;
y: number;
};
declare function getRealCoords(el: HTMLElement): Coordinates;

export { type BaseDragState, type Coordinates, type DNDPlugin, type DNDPluginData, type DragAndDrop, type DragAndDropData, type DragState, type DragStateProps, type DragendEvent, type DragendEventData, type DragstartEvent, type DragstartEventData, type DropSwapConfig, type DropSwapState, type DynamicValuesData, type EventHandlers, type InsertConfig, type InsertEvent, type InsertState, type NativeDragEffects, type Node, type NodeData, type NodeDragEventData, type NodeEvent, type NodeEventData, type NodeFromPoint, type NodePointerEventData, type NodeRecord, type NodeTargetData, type NodesData, type ParentConfig, type ParentData, type ParentDragEventData, type ParentEventData, type ParentFromPoint, type ParentKeydownEventData, type ParentObservers, type ParentPointerEventData, type ParentRecord, type ParentTargetData, type ParentsData, type PluginData, type PointeroverNodeEvent, type PointeroverParentEvent, type RemapFinished, type RemapFinishedData, type ScrollData, type SetupNode, type SetupNodeData, type ShouldSwapData, type SortEvent, type SortEventData, type StateEvents, type SynthDragState, type SynthDragStateProps, type TearDownNode, type TearDownNodeData, type TransferEvent, type TransferEventData, addClass, addEvents, addNodeClass, addParentClass, animations, copyNodeStyle, createEmitter, dragAndDrop, dragStateProps, dragValues, dragstartClasses, dropOrSwap, emit, eq, eqRegExp, eventCoordinates, getElFromPoint, getRealCoords, getScrollablesUnderPointer, handleClickNode, handleClickParent, handleDragend, handleDragstart, handleEnd, handleLongPress, handleNodeDragover, handleNodeDrop, handleNodeKeydown, handleNodePointerdown, handleNodePointerover, handleNodePointerup, handleParentBlur, handleParentDragover, handleParentDrop, handleParentFocus, handleParentKeydown, handleParentPointerover, handlePointercancel, initDrag, insert, isBrowser, isDragState, isNode, isSynthDragState, noDefault, nodeEventData, nodes, on, parentEventData, parentValues, parents, performSort, performTransfer, preventSortOnScroll, remapFinished, remapNodes, removeClass, resetState, setAttrs, setDragState, setParentValues, setupNode, setupNodeRemap, sort, state, synthMove, tearDown, tearDownNode, tearDownNodeRemap, throttle, transfer, treeAncestors, updateConfig, validateDragHandle, validateDragstart, validateSort, validateTransfer };
export { type BaseDragState, type Coordinates, type DNDPlugin, type DNDPluginData, type DragAndDrop, type DragAndDropData, type DragState, type DragStateProps, type DragendEvent, type DragendEventData, type DragstartEvent, type DragstartEventData, type DropSwapConfig, type DropSwapState, type DynamicValuesData, type EventHandlers, type InsertConfig, type InsertEvent, type InsertState, type NativeDragEffects, type Node, type NodeData, type NodeDragEventData, type NodeEvent, type NodeEventData, type NodeFromPoint, type NodePointerEventData, type NodeRecord, type NodeTargetData, type NodesData, type ParentConfig, type ParentData, type ParentDragEventData, type ParentEventData, type ParentFromPoint, type ParentKeydownEventData, type ParentObservers, type ParentPointerEventData, type ParentRecord, type ParentTargetData, type ParentsData, type PluginData, type PointeroverNodeEvent, type PointeroverParentEvent, type RemapFinished, type RemapFinishedData, type ScrollData, type SetupNode, type SetupNodeData, type ShouldSwapData, type SortEvent, type SortEventData, type StateEvents, type SynthDragState, type SynthDragStateProps, type TearDownNode, type TearDownNodeData, type TransferEvent, type TransferEventData, addClass, addEvents, addNodeClass, addParentClass, animations, createEmitter, dragAndDrop, dragStateProps, dragValues, dragstartClasses, dropOrSwap, emit, eq, eqRegExp, eventCoordinates, getElFromPoint, getRealCoords, getScrollablesUnderPointer, handleClickNode, handleClickParent, handleDragend, handleDragstart, handleEnd, handleLongPress, handleNodeDragover, handleNodeDrop, handleNodeKeydown, handleNodePointerdown, handleNodePointerover, handleNodePointerup, handleParentBlur, handleParentDragover, handleParentDrop, handleParentFocus, handleParentKeydown, handleParentPointerover, handlePointercancel, initDrag, insert, isBrowser, isDragState, isNode, isSynthDragState, noDefault, nodeEventData, nodes, on, parentEventData, parentValues, parents, performSort, performTransfer, preventSortOnScroll, remapFinished, remapNodes, removeClass, resetState, setAttrs, setDragState, setParentValues, setupNode, setupNodeRemap, sort, state, synthMove, tearDown, tearDownNode, tearDownNodeRemap, throttle, transfer, treeAncestors, updateConfig, validateDragHandle, validateDragstart, validateSort, validateTransfer };
3 changes: 1 addition & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1108,11 +1108,10 @@ declare function isNode(el: unknown): el is Node;
* @returns - The abort controller used for the event listeners.
*/
declare function addEvents(el: Document | ShadowRoot | Node | HTMLElement | Window, events: EventHandlers | any): AbortController;
declare function copyNodeStyle(sourceNode: HTMLElement, targetNode: HTMLElement, omitKeys?: boolean): void;
declare function eventCoordinates(data: DragEvent | PointerEvent): {
x: number;
y: number;
};
declare function getRealCoords(el: HTMLElement): Coordinates;

export { type BaseDragState, type Coordinates, type DNDPlugin, type DNDPluginData, type DragAndDrop, type DragAndDropData, type DragState, type DragStateProps, type DragendEvent, type DragendEventData, type DragstartEvent, type DragstartEventData, type DropSwapConfig, type DropSwapState, type DynamicValuesData, type EventHandlers, type InsertConfig, type InsertEvent, type InsertState, type NativeDragEffects, type Node, type NodeData, type NodeDragEventData, type NodeEvent, type NodeEventData, type NodeFromPoint, type NodePointerEventData, type NodeRecord, type NodeTargetData, type NodesData, type ParentConfig, type ParentData, type ParentDragEventData, type ParentEventData, type ParentFromPoint, type ParentKeydownEventData, type ParentObservers, type ParentPointerEventData, type ParentRecord, type ParentTargetData, type ParentsData, type PluginData, type PointeroverNodeEvent, type PointeroverParentEvent, type RemapFinished, type RemapFinishedData, type ScrollData, type SetupNode, type SetupNodeData, type ShouldSwapData, type SortEvent, type SortEventData, type StateEvents, type SynthDragState, type SynthDragStateProps, type TearDownNode, type TearDownNodeData, type TransferEvent, type TransferEventData, addClass, addEvents, addNodeClass, addParentClass, animations, copyNodeStyle, createEmitter, dragAndDrop, dragStateProps, dragValues, dragstartClasses, dropOrSwap, emit, eq, eqRegExp, eventCoordinates, getElFromPoint, getRealCoords, getScrollablesUnderPointer, handleClickNode, handleClickParent, handleDragend, handleDragstart, handleEnd, handleLongPress, handleNodeDragover, handleNodeDrop, handleNodeKeydown, handleNodePointerdown, handleNodePointerover, handleNodePointerup, handleParentBlur, handleParentDragover, handleParentDrop, handleParentFocus, handleParentKeydown, handleParentPointerover, handlePointercancel, initDrag, insert, isBrowser, isDragState, isNode, isSynthDragState, noDefault, nodeEventData, nodes, on, parentEventData, parentValues, parents, performSort, performTransfer, preventSortOnScroll, remapFinished, remapNodes, removeClass, resetState, setAttrs, setDragState, setParentValues, setupNode, setupNodeRemap, sort, state, synthMove, tearDown, tearDownNode, tearDownNodeRemap, throttle, transfer, treeAncestors, updateConfig, validateDragHandle, validateDragstart, validateSort, validateTransfer };
export { type BaseDragState, type Coordinates, type DNDPlugin, type DNDPluginData, type DragAndDrop, type DragAndDropData, type DragState, type DragStateProps, type DragendEvent, type DragendEventData, type DragstartEvent, type DragstartEventData, type DropSwapConfig, type DropSwapState, type DynamicValuesData, type EventHandlers, type InsertConfig, type InsertEvent, type InsertState, type NativeDragEffects, type Node, type NodeData, type NodeDragEventData, type NodeEvent, type NodeEventData, type NodeFromPoint, type NodePointerEventData, type NodeRecord, type NodeTargetData, type NodesData, type ParentConfig, type ParentData, type ParentDragEventData, type ParentEventData, type ParentFromPoint, type ParentKeydownEventData, type ParentObservers, type ParentPointerEventData, type ParentRecord, type ParentTargetData, type ParentsData, type PluginData, type PointeroverNodeEvent, type PointeroverParentEvent, type RemapFinished, type RemapFinishedData, type ScrollData, type SetupNode, type SetupNodeData, type ShouldSwapData, type SortEvent, type SortEventData, type StateEvents, type SynthDragState, type SynthDragStateProps, type TearDownNode, type TearDownNodeData, type TransferEvent, type TransferEventData, addClass, addEvents, addNodeClass, addParentClass, animations, createEmitter, dragAndDrop, dragStateProps, dragValues, dragstartClasses, dropOrSwap, emit, eq, eqRegExp, eventCoordinates, getElFromPoint, getRealCoords, getScrollablesUnderPointer, handleClickNode, handleClickParent, handleDragend, handleDragstart, handleEnd, handleLongPress, handleNodeDragover, handleNodeDrop, handleNodeKeydown, handleNodePointerdown, handleNodePointerover, handleNodePointerup, handleParentBlur, handleParentDragover, handleParentDrop, handleParentFocus, handleParentKeydown, handleParentPointerover, handlePointercancel, initDrag, insert, isBrowser, isDragState, isNode, isSynthDragState, noDefault, nodeEventData, nodes, on, parentEventData, parentValues, parents, performSort, performTransfer, preventSortOnScroll, remapFinished, remapNodes, removeClass, resetState, setAttrs, setDragState, setParentValues, setupNode, setupNodeRemap, sort, state, synthMove, tearDown, tearDownNode, tearDownNodeRemap, throttle, transfer, treeAncestors, updateConfig, validateDragHandle, validateDragstart, validateSort, validateTransfer };
29 changes: 0 additions & 29 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,6 @@ function initDrag(data, draggedNodes2) {
const clonedNode = node.el.cloneNode(true);
clonedNode.style.pointerEvents = "none";
clonedNode.id = node.el.id + "-clone";
copyNodeStyle(node.el, clonedNode, true);
wrapper.append(clonedNode);
}
const { width } = draggedNodes2[0].el.getBoundingClientRect();
Expand Down Expand Up @@ -2865,33 +2864,6 @@ function addEvents(el, events) {
}
return abortController;
}
function copyNodeStyle(sourceNode, targetNode, omitKeys = false) {
const computedStyle = window.getComputedStyle(sourceNode);
const omittedKeysSet = /* @__PURE__ */ new Set([
"position",
"z-index",
"top",
"left",
"x",
"pointer-events",
"y",
"transform-origin",
"filter",
"-webkit-text-fill-color"
]);
let styles = "";
for (const key of Array.from(computedStyle)) {
if (omitKeys === false && key && omittedKeysSet.has(key)) continue;
const value = computedStyle.getPropertyValue(key);
const priority = computedStyle.getPropertyPriority(key);
styles += `${key}: ${value}${priority ? " !important" : ""}; `;
}
targetNode.style.cssText += styles;
targetNode.style.pointerEvents = "none";
const sourceChildren = Array.from(sourceNode.children);
const targetChildren = Array.from(targetNode.children);
if (sourceChildren.length === 0 || targetChildren.length === 0) return;
}
function eventCoordinates(data) {
return { x: data.clientX, y: data.clientY };
}
Expand All @@ -2918,7 +2890,6 @@ export {
addNodeClass,
addParentClass,
animations,
copyNodeStyle,
createEmitter,
dragAndDrop,
dragStateProps,
Expand Down
2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

49 changes: 0 additions & 49 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1588,8 +1588,6 @@ export function initDrag<T>(

clonedNode.id = node.el.id + "-clone";

copyNodeStyle(node.el, clonedNode, true);

wrapper.append(clonedNode);
}

Expand Down Expand Up @@ -1989,12 +1987,8 @@ function initSynthDrag<T>(
for (const node of draggedNodes) {
const clonedNode = node.el.cloneNode(true) as HTMLElement;

//copyNodeStyle(node.el, clonedNode);

clonedNode.style.pointerEvents = "none";

//clonedNode.id = node.el.id + "-clone";

wrapper.append(clonedNode);
}

Expand Down Expand Up @@ -2975,49 +2969,6 @@ export function addEvents(
return abortController;
}

export function copyNodeStyle(
sourceNode: HTMLElement,
targetNode: HTMLElement,
omitKeys = false
) {
const computedStyle = window.getComputedStyle(sourceNode);
const omittedKeysSet = new Set([
"position",
"z-index",
"top",
"left",
"x",
"pointer-events",
"y",
"transform-origin",
"filter",
"-webkit-text-fill-color",
]);

// Batch style updates
let styles = "";
for (const key of Array.from(computedStyle)) {
if (omitKeys === false && key && omittedKeysSet.has(key)) continue;
const value = computedStyle.getPropertyValue(key);
const priority = computedStyle.getPropertyPriority(key);
styles += `${key}: ${value}${priority ? " !important" : ""}; `;
}
targetNode.style.cssText += styles;
targetNode.style.pointerEvents = "none";

const sourceChildren = Array.from(sourceNode.children);
const targetChildren = Array.from(targetNode.children);

if (sourceChildren.length === 0 || targetChildren.length === 0) return;

//sourceChildren.forEach((child, index) => {
// const targetChild = targetChildren[index];
// if (!isNode(child) || !isNode(targetChild)) return;

// copyNodeStyle(child as HTMLElement, targetChild as HTMLElement, omitKeys);
//});
}

export function eventCoordinates(data: DragEvent | PointerEvent) {
return { x: data.clientX, y: data.clientY };
}
Expand Down

0 comments on commit 30a5bbc

Please sign in to comment.