locateTask
Description
Locates the task and its HTML element from a mouse or drag eventYou can import the helper from @svar-ui/vue-gantt.
Usage
locateTask(ev: MouseEvent | DragEvent, api?: IApi): { id: string | number, node: HTMLElement } | null
Parameters
ev- (required) theMouseEventorDragEventto locate a task fromapi- (optional) the Gantt API object; without it, a task is found only when the pointer is over a task bar or a grid row
Returns
Returns an object with the matched task id and its DOM node (a grid row or a chart bar), or null if ev doesn't target a task.
Example
import { Gantt, locateTask } from "@svar-ui/vue-gantt";
function onDrop(e) {
const target = locateTask(e, api);
if (!target) return;
// target.id, target.node
}
For full drag-and-drop use cases built on locateTask, see Add tasks by drag and drop from outside and Assign resources by drag and drop.
Related samples:
Related articles: