onMouseMove

fires when the mouse is moved over the gantt container

void onMouseMove(string|number id,Event e){ ... };

Parameters

idstring|numberthe id of the task that the mouse is moved over
eEventa 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: "<span id='pointer-date'></span>"
});
 
var formatDate = gantt.date.date_to_str("%Y-%m-%d %H:%i");
gantt.attachEvent("onMouseMove", function (id, e){
    var helper = gantt.utils.dom;
    if(helper.isChildOf(e.target, gantt.$task_data)){
        var textContainer = document.querySelector("#pointer-date");
        var pos = helper.getRelativeEventPosition(e, gantt.$task_data);
        var pointerDate = gantt.dateFromPos(pos.x);
        textContainer.innerText = formatDate(pointerDate);
    }
});

Related sample:  Getting date-time under the mouse cursor

See also
Back to top