-
-
Notifications
You must be signed in to change notification settings - Fork 740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete connection [x] button is displayed out of place on a smartphone #407
Comments
Does it happen on android too? To rule out it being a safari issue. First try to leave-normal and see if it shows normal. (CSS, and Javascript) If it shows ok! It is a problem of its implementation, if not safari or create a demo that we could check. |
Yes this is an issue with the touch event, Safari doesn't have Touch.client[XY] (https://developer.mozilla.org/en-US/docs/Web/API/Touch/clientX#browser_compatibility) so that value is undefined at Line 535 in abb241b
Changing this to deletebox.style.top = (e.clientY || e.pageY) * ( this.precanvas.clientHeight ...... appears to resolve the issue. There may be other issues on Safari touch devices where e.clientXY are used in the code. |
@jerosoler I've only tested on Safari (iPhone) and Chrome (iPhone) and has that bug, but not tested on Android as I don't have an Android phone. I will try source one and test it. @27pchrisl Thanks for the feedback. It seems like it is a Safari bug (touch event). I'm running the "drawflow.min.js" and I can't see that line of code you've referenced so I can change it. |
Please try: const editor = new Drawflow(id);
editor.contextmenu = function(e) {
this.dispatch('contextmenu', e);
if (e.type === "touchmove") {
var e_pos_x = e.touches[0].clientX;
var e_pos_y = e.touches[0].clientY;
} else {
var e_pos_x = e.clientX;
var e_pos_y = e.clientY;
}
e.preventDefault();
if(this.editor_mode === 'fixed' || this.editor_mode === 'view') {
return false;
}
if(this.precanvas.getElementsByClassName("drawflow-delete").length) {
this.precanvas.getElementsByClassName("drawflow-delete")[0].remove()
};
if(this.node_selected || this.connection_selected) {
var deletebox = document.createElement('div');
deletebox.classList.add("drawflow-delete");
deletebox.innerHTML = "x";
if(this.node_selected) {
this.node_selected.appendChild(deletebox);
}
if(this.connection_selected) {
deletebox.style.top = e_pos_y * ( this.precanvas.clientHeight / (this.precanvas.clientHeight * this.zoom)) - (this.precanvas.getBoundingClientRect().y * ( this.precanvas.clientHeight / (this.precanvas.clientHeight * this.zoom)) ) + "px";
deletebox.style.left = e_pos_x * ( this.precanvas.clientWidth / (this.precanvas.clientWidth * this.zoom)) - (this.precanvas.getBoundingClientRect().x * ( this.precanvas.clientWidth / (this.precanvas.clientWidth * this.zoom)) ) + "px";
this.precanvas.appendChild(deletebox);
}
}
}
editor.start(); Add function between And test in Iphone. |
This did not work as is - the event comes through as a |
Perfect! I'll upload it tomorrow! ;) |
I can confirm the above function solved the issue on Safari/smartphone and it now shows the delete icon next to the line. However there is another strange behaviour I noticed on the phone which could be related to the touch event: How to replicate issue: |
I've updated the script so that the "drawflow-delete" icon shows up on a "click" event.
On a desktop (Chrome or Firefox) this is working well, and shows the "x" button on (or close by) the connection line once you click on the line, but on a smartphone (iPhone 13) when you tap the connection line, the button is being placed in weird places, very far away from the connection line.
I've attached a screenshot for reference of what it looks like on a smartphone (see below).
Is this an issue with the "touch" event or something else? Any guidance is appreciated.
thanks.
The text was updated successfully, but these errors were encountered: