frappe / gantt

Open Source Javascript Gantt
https://frappe.io/gantt
MIT License
4.77k stars 1.06k forks source link

Touch support stopped working #406

Open jesben opened 4 months ago

jesben commented 4 months ago

Thanks for a great lib to all those who contributed!

When this library switched to mousedown, mousemove and mouseup from drag "onmove, onstart and onstop" for bar events, touch support stopped working (Tested on iOS). Tried to implement it with touchstart, touchmove and touchend, but scrollbar from container messes it up and dragging bar doesn't run smoothly. Anyone have a solution for this?

Both mouse and touch works in the demo! The demo runs with a very old version. Version 0.0.7 is the last version that uses onmove, onstart and onstop.

To get offsetX and offsetY, I have tried with touchstart:

const rect = e.target.getBoundingClientRect();
x_on_start = e.targetTouches[0].clientX - rect.x;
y_on_start = e.targetTouches[0].clientY - rect.y;

touchend:

const rect = e.target.getBoundingClientRect();
let offsetX = e.targetTouches[0].clientX - rect.x;
let offsetY = e.targetTouches[0].clientY - rect.y;
jesben commented 4 months ago
x_on_start = e.touches[0].clientX;
y_on_start = e.touches[0].clientY;
let offsetX = e.touches[0].clientX;
let offsetY = e.touches[0].clientY;

Is working :)

safwansamsudeen commented 3 days ago

Thanks for this note! We'll push this fix soon.