onMouseMove
Description
Fires when the mouse is moved over the gantt container
onMouseMove: (id: string | number, e: Event) => void;
Parameters
id- (required) string | number - the id of the task that the mouse is moved overe- (required) Event - a native event object
Example
gantt.attachEvent("onMouseMove", function (id, e){
//any custom logic here
});
Details
This event is an alias of the native mousemove event handler attached to the gantt.$root element.
When the event target is a node of a task element, the related task id will be passed into the first argument. Otherwise, the first argument will be null.
gantt.message({
expire: -1,
text: ""
});
const formatDate = gantt.date.date_to_str("%Y-%m-%d %H:%i");
gantt.attachEvent("onMouseMove", function (id, e){
const helper = gantt.utils.dom;
if(helper.isChildOf(e.target, gantt.$task_data)){
const textContainer = document.querySelector("#pointer-date");
const pos = helper.getRelativeEventPosition(e, gantt.$task_data);
const pointerDate = gantt.dateFromPos(pos.x);
textContainer.innerText = formatDate(pointerDate);
}
});
note