Skip to content
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

dia.Paper: blank:contextmenu event is fired differently on MacOS and Windows #1590

Closed
ITfanheng opened this issue Dec 22, 2021 · 12 comments · Fixed by #1727
Closed

dia.Paper: blank:contextmenu event is fired differently on MacOS and Windows #1590

ITfanheng opened this issue Dec 22, 2021 · 12 comments · Fixed by #1727
Assignees
Labels

Comments

@ITfanheng
Copy link

ITfanheng commented Dec 22, 2021

I noticed that right click dragging paper has different performance in different OS.
such as mac and windows.
https://resources.jointjs.com/demos/bpmn
How can i keep it in the same performance, Thanks in advance.

@kumilingus
Copy link
Contributor

What does it do on Windows?

@ddszsad
Copy link

ddszsad commented Dec 22, 2021

on mac :
mousedown mousemove mouseup. drag over
on windows :
mosuedown mouseup mousemove leftClick. drag over

@kumilingus
Copy link
Contributor

I am sorry, I don't understand. What is exactly leftClick and drag over? How do you observe that the order of events is different (mousedown mouseup mousemove)?

@ddszsad
Copy link

ddszsad commented Dec 22, 2021

it's my fault, my poor english.
But you can open the url in windows and mac. Then draging the demo.
i mean contextMenu has different performance in windows and mac.

@kumilingus
Copy link
Contributor

Right, we've tried both and can't see anything wrong (in Chrome on Win and macOS). Could share a video perhaps?

@ddszsad
Copy link

ddszsad commented Dec 22, 2021

Sorry, i don't konw how to express what i mean

@meng-jpg
Copy link

on mac : mousedown mousemove mouseup. drag over on windows : mosuedown mouseup mousemove leftClick. drag over
Is that means when you want to drag a paper on MAC, you need to hold down the mouse, but on Windows, you need click to start dragging, and click again to finish the drag?

@inlann
Copy link

inlann commented Dec 22, 2021

I tested the bpmn demo in Chrome on MacOS and Windows and the behavior of drag & drop is different.
On MacOS, I hold down the right mouse button to drag the canvas, and I release the right mouse button to drop it.
On Windows, I could drag the canvas with a single right mouse click, but needed to click the left mouse button again to drop it.

@kumilingus
Copy link
Contributor

Ok, thanks, everyone. We'll look into it.

@kumilingus
Copy link
Contributor

Windows - contextmenu fired on mouseup
Mac - contextmenu fired on mousedown

We have to deal with this on our side and trigger an event ourselves similarly to - mapbox/mapbox-gl-js#3803

@kumilingus kumilingus added the bug label Dec 22, 2021
@kumilingus kumilingus changed the title Right click dragging paper has Difference on demo dia.Paper: blank:contextmenu event is fired differently on MacOS and Windows Dec 22, 2021
@kumilingus
Copy link
Contributor

A workaround for the time being:

joint.dia.Paper.prototype.pointerdown = function(evt) {
    evt = joint.util.normalizeEvent(evt);
    var view = this.findView(evt.target);
    var isContextmenu = false;
    if (this.guard(evt, view)) {
        if (evt.type !== 'mousedown' || evt.button !== 2) return;
        isContextmenu = true;
    }
    var localPoint = this.snapToGrid(evt.clientX, evt.clientY);
    if (view) {
        evt.preventDefault();
        view.pointerdown(evt, localPoint.x, localPoint.y);
    } else {
        if (this.options.preventDefaultBlankAction) evt.preventDefault();
        this.trigger('blank:pointerdown', evt, localPoint.x, localPoint.y);
    }

    if (isContextmenu) {
        setTimeout(() => {  this.delegateDragEvents(view, evt.data); }, 0);
    } else {
        this.delegateDragEvents(view, evt.data);
    }
};

paper.delegateEvents();

paper.on({

    'blank:pointerdown': function(evt, x, y) {
        if (evt.button === 2) {
            evt.preventDefault();
            paperScroller.startPanning(evt, x, y);
        } else {
            closeTools();
            selection.startSelecting(evt, x, y);
        }
    }
});

@github-actions
Copy link

github-actions bot commented May 5, 2022

This issue is stale because it has been open 60 days with no activity. Please remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale This issue/PR shows no activity for an extended period of time. label May 5, 2022
@kumilingus kumilingus removed the stale This issue/PR shows no activity for an extended period of time. label May 5, 2022
@Geliogabalus Geliogabalus self-assigned this Jun 30, 2022
@Geliogabalus Geliogabalus linked a pull request Jul 8, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants