Skip to content

Commit

Permalink
chore: update config
Browse files Browse the repository at this point in the history
  • Loading branch information
cqh963852 committed Aug 30, 2024
1 parent b004968 commit ed4e614
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions packages/dnd-core/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const config = {
format: "cjs",
},
],
external: ["events"],
};

export default config;
16 changes: 3 additions & 13 deletions packages/dnd-core/src/Dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ import DragListenable from "./DragListenable";
import DropListenable from "./DropListenable";
import { IDragItem } from "./type";

export enum DND_EVENT {
DRAG = "DND_EVENT/DRAG",
DRAG_END = "DND_EVENT/DRAG_END",
DRAG_ENTER = "DND_EVENT/DRAG_ENTER",
DRAG_LEAVE = "DND_EVENT/DRAG_LEAVE",
DRAG_OVER = "DND_EVENT/DRAG_OVER",
DRAG_START = "DND_EVENT/DRAG_START",
DROP = "DND_EVENT/DROP",
}

class Dnd {
private dragging = false;
private _dropped = false;
Expand All @@ -23,13 +13,13 @@ class Dnd {
options?: {
native?: boolean;
item?: I;
}
},
) {
const listenable = new DragListenable(
this,
ele,
options?.native,
options?.item
options?.item,
);

return listenable;
Expand All @@ -40,7 +30,7 @@ class Dnd {
options?: {
native?: boolean;
allowBubble?: boolean;
}
},
) {
const listenable = new DropListenable(this, ele, options?.native);
return listenable;
Expand Down
6 changes: 3 additions & 3 deletions packages/dnd-core/src/DragListenable.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EventEmitter } from "events";

import Dnd, { DND_EVENT } from "./Dnd";
import Dnd from "./Dnd";
import isHTMLElement from "./isHTMLElement";
import offsetFromEvent from "./offsetFromEvent";
import { IDragItem } from "./type";
import { DND_EVENT, IDragItem } from "./type";
import { IDragData, IPoint, VECTOR } from "./type";
import vectorFromEvent from "./vectorFromEvent";

Expand All @@ -14,7 +14,7 @@ declare interface DragListenable<E extends HTMLElement, I extends IDragItem> {

class DragListenable<
E extends HTMLElement = HTMLElement,
I extends IDragItem = IDragItem
I extends IDragItem = IDragItem,
> extends EventEmitter {
private dnd: Dnd;
private dragStartEmitted = false;
Expand Down
4 changes: 2 additions & 2 deletions packages/dnd-core/src/DropListenable.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EventEmitter } from "events";

import Dnd, { DND_EVENT } from "./Dnd";
import Dnd from "./Dnd";
import isHTMLElement from "./isHTMLElement";
import { IDragItem } from "./type";
import { DND_EVENT, IDragItem } from "./type";
import { IDropData, IPoint } from "./type";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
10 changes: 10 additions & 0 deletions packages/dnd-core/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ export interface IPoint {
x: number;
y: number;
}

export enum DND_EVENT {
DRAG = "DND_EVENT/DRAG",
DRAG_END = "DND_EVENT/DRAG_END",
DRAG_ENTER = "DND_EVENT/DRAG_ENTER",
DRAG_LEAVE = "DND_EVENT/DRAG_LEAVE",
DRAG_OVER = "DND_EVENT/DRAG_OVER",
DRAG_START = "DND_EVENT/DRAG_START",
DROP = "DND_EVENT/DROP",
}

0 comments on commit ed4e614

Please sign in to comment.