DHTMLX / scheduler

GPL version of JavaScript Event Scheduler
https://dhtmlx.com/docs/products/dhtmlxScheduler/
GNU General Public License v2.0
311 stars 110 forks source link

Event creation doesn’t start at clicked date #13

Closed gm-olivier closed 6 years ago

gm-olivier commented 8 years ago

If you’re a bit fast when you start dragging after clicking to create an event (i.e. if you act normally and don’t intentionally wait after clicking before you start dragging), the event does not start where you clicked but later.

That’s because in scheduler._on_mouse_move, you calculate the start date from the position of the mouse move event instead of the position of the mouse down event (https://github.com/DHTMLX/scheduler/blob/master/codebase/sources/dhtmlxscheduler.js#L2377):

// position of the mouse moved event
var pos=this._mouse_coords(e);
// ...
// replace the position of the start of the drag by the position of the first mouse moved event
this._drag_pos=pos;
this._drag_pos.has_moved = true;
// ...
// calculate the start date from the replaced position
start = this._get_date_from_pos(pos).valueOf();

I think that this._drag_pos=pos is unnecessary, and that the start date should be calculated from the original drag position (mouse down position):

var pos=this._mouse_coords(e);
// ...
// don’t change the position of the start of the drag
this._drag_pos.has_moved = true;
// ...
// calculate the start date from the mouse down position
start = this._get_date_from_pos(this._drag_pos).valueOf();
AlexKlimenkov commented 6 years ago

Fixed in the latest builds of scheduler, this repo will be updated after public release