You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another main question is to make sure the plugin functions execute once and only once. If user has disabled: disabledState, this will cause entire object to be recreated, hence resetting the plugin functions and their states also. Maybe can be solved with privateState that is stored in neodrag itself. But seems hacky. We should make sure these functions are not recreated, or if it is unavoidable, they are idempotent enough
Plugin API
Rough sketch of how it looks.
typeState={// Raw movement from pointer event (read-only)readonlydx: number;readonlydy: number;// Current position (mutable)x: number;y: number;// Drag statusisDragging: boolean;// Element referenceelement: HTMLElement;// Starting pointinitial: {x: number;y: number};}typePlugin={// Identifier for the pluginname: string;// When plugin runs:// 'pre' - early, for modifying input (like grid, axis)// 'post' - late, for applying constraints (like bounds)phase: 'pre'|'post';// Called when plugin is initializedsetup?: (context: {element: HTMLElement;state: State;})=>void;// Start of drag - return false to prevent dragdragStart?: (state: State,event: PointerEvent)=>Partial<State>|false|void;// During drag - return state modificationsdrag?: (state: State,event: PointerEvent)=>Partial<State>|void;// End of dragdragEnd?: (state: State,event: PointerEvent)=>Partial<State>|void;// Cleanup when draggable is destroyedcleanup?: ()=>void;}
The text was updated successfully, but these errors were encountered:
Thinking of this API:
This will be the base API.
And the candidates for plugins:
handleMerge handle cancel under onecontrols
plugincancelPossibly position also has to be in the base properties, being a fundamental property.
Usage:
Another main question is to make sure the plugin functions execute once and only once. If user has
disabled: disabledState
, this will cause entire object to be recreated, hence resetting the plugin functions and their states also. Maybe can be solved withprivateState
that is stored in neodrag itself. But seems hacky. We should make sure these functions are not recreated, or if it is unavoidable, they are idempotent enoughPlugin API
Rough sketch of how it looks.
The text was updated successfully, but these errors were encountered: