frappe / gantt

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

Touch support stopped working #406

Open jesben opened 3 months ago

jesben commented 3 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 2 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 :)