Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted Dragster code into TypeScript #50

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"ecmaVersion": 2018, // Allows for the parsing of modern ECMAScript features
"sourceType": "module" // Allows for the use of imports
},
"ignorePatterns": ["/dist"],
"plugins": ["cypress"],
"rules": {
"eqeqeq": ["error", "always"],
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"printWidth": 80,
"tabWidth": 4
}

86 changes: 86 additions & 0 deletions dist/dragster.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
declare const CLASS_DRAGGING = "is-dragging";
declare const CLASS_DRAGOVER = "is-drag-over";
declare const CLASS_DRAGGABLE = "dragster-draggable";
declare const CLASS_REGION = "dragster-drag-region";
declare const CLASS_PLACEHOLDER = "dragster-drop-placeholder";
declare const CLASS_TEMP_ELEMENT = "dragster-temp";
declare const CLASS_TEMP_CONTAINER = "dragster-temp-container";
declare const CLASS_HIDDEN = "dragster-is-hidden";
declare const CLASS_REPLACABLE = "dragster-replacable";
declare const EVT_TOUCHSTART = "touchstart";
declare const EVT_TOUCHMOVE = "touchmove";
declare const EVT_TOUCHEND = "touchend";
declare const EVT_MOUSEDOWN = "mousedown";
declare const EVT_MOUSEMOVE = "mousemove";
declare const EVT_MOUSEUP = "mouseup";
declare const UNIT = "px";
declare const DIV = "div";
declare enum EPosition {
top = "top",
bottom = "bottom"
}
interface IDragsterParams {
elementSelector: string;
regionSelector: string;
dragOnlyRegionCssClass: string;
shouldReplaceElements: boolean;
shouldUpdateRegionsHeight: boolean;
minimumRegionHeight: number;
onBeforeDragStart: (event: TDragsterEvent) => boolean;
onAfterDragStart: (event: TDragsterEvent) => boolean;
onBeforeDragMove: (event: TDragsterEvent) => boolean;
onAfterDragMove: (event: TDragsterEvent) => boolean;
onBeforeDragEnd: (event: TDragsterEvent) => boolean;
onAfterDragEnd: (event: TDragsterEvent) => boolean;
onAfterDragDrop: (event: TDragsterEvent) => boolean;
shouldScrollWindowOnDrag: boolean;
isDragOnlyRegionsEnabled: boolean;
shouldCloneElements: boolean;
shouldWrapDraggableElements: boolean;
shouldPlaceShadowElementUnderMouse: boolean;
}
interface IDragsterOutput {
destroy: () => void;
update: () => void;
updateRegions: () => void;
}
declare type TPlaceholderPosition = 'top' | 'bottom' | null;
interface IDragsterEventInfo {
drag: {
node: HTMLElement | null;
};
drop: {
node: HTMLElement | null;
};
shadow: {
node: HTMLElement | null;
top: number;
left: number;
};
placeholder: {
node: HTMLElement | null;
position: TPlaceholderPosition;
};
dropped: {
node: HTMLElement | null;
};
clonedFrom: {
node: HTMLElement | null;
};
clonedTo: {
node: HTMLElement | null;
};
}
declare type TDragsterEvent = MouseEvent & {
dragster: IDragsterEventInfo;
};
declare type TDragster = (params: Partial<IDragsterParams>) => IDragsterOutput;
declare const checkIsTouchEvent: (event: unknown) => event is TouchEvent;
declare const checkIsUIEvent: (event: unknown) => event is UIEvent;
declare type TScrollWindowEvent = WheelEvent | TouchEvent | TDragsterEvent;
declare type TInitDragsterEventInfo = () => (options?: Partial<IDragsterEventInfo>) => IDragsterEventInfo;
/**
* Scrolls window while dragging an element
*/
declare const scrollWindow: (event: TScrollWindowEvent) => void;
declare const Dragster: TDragster;
Loading