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

Refine drag and drop events to prevent interference with other drag/drop-sensitive fields in downstream use cases #2

Merged
merged 2 commits into from
Jun 23, 2020

Conversation

NitinBhasneria
Copy link

@NitinBhasneria NitinBhasneria commented Jun 1, 2020

This will improve publiclab/PublicLab.Editor#504.
After this fix, the drag and drop popup will only appear when it drags into proper div. Hence, in the editor module, the unnecessary popup will not appear.
Now if we drag and drop the image in Main Image Module the editor will not have a drag nd drop popup.

woofmark2

In this PR I have added one function that is dragginstopforce() this function will forcibly stop the CSS popup without checking the condition of entre or leave (i.e, it will not check the variable draggingCss===0). This function will be called every time on event mouseout and dragend.
Other than this function the pre-existing function are dragging() called on dragenter this function will add CSS popup including the draggingCss++ , handledragover called on dragover this will add CSS popup including stop(e) and draggingstop() called on dragover.
The flow will be like this:- When the drag enters in the container the dragenter event calls dragging() function after this the dragging in the container will be handled by dragover and on leaving the container the event dragover will call the dragginstop.
In this process is the mouseout or dragend event occurs then draggingstopforce will be called.
Thank you.

@NitinBhasneria
Copy link
Author

@VladimirMikulic
Copy link

Please document your code.

@NitinBhasneria
Copy link
Author

Ok @VladimirMikulic I will add some comment and explanation in short time.

In this PR, the dragging container css is changed such that whenever we drag any image to the container it will show the `drag and drop` popup and when we drag out the image from that container this popup will disappear.
The thing which will look better after this:- Presently, when we drag the image anywhere in the editor it will display a popup of `drag and drop` which is not a good UI or experience to have because we have another drag and drop too which is MainImage Module. After this PR the popup will only appear we dargin the image over that particular container.
@shreyaa-s-zz
Copy link

Can you explain how it works for dragover?

@NitinBhasneria
Copy link
Author

@Shreyaa-s by dragover in the container, the function handleDragOver will be called. By this function, the popup CSS, stop(e) cancels the event and e.dataTransfer.dropEffect = 'copy'; will be added.

@keshav234156
Copy link

keshav234156 commented Jun 2, 2020

@NitinBhasneria Ok, It works well. Can you please document what each of the function does, so that code becomes easy to understand

@NitinBhasneria
Copy link
Author

@keshav234156 yea, cool.
I have edited the main comment on PR.

@jywarren
Copy link
Owner

jywarren commented Jun 3, 2020

This looks great. Just curious about the workflow I proposed in this comment, in terms of how we merge this in! Thank you!

publiclab/PublicLab.Editor#490 (comment)

If you like it, we can open new PRs against those branches and link from here to them, and close this one. Thank you!!!

@NitinBhasneria
Copy link
Author

NitinBhasneria commented Jun 3, 2020

OK, so I am a little confused in the comment @jywarren.
I just want to confirm. According to you, we can directly fork the https://github.com/jywarren/woofmark but you suggest to open a discrete PRs in bevacqua/woofmark.
So here I like your idea. By this we can track the new features and changes in bevacqua/woofmark. Also, wanted to know if xhrOptionsAltBureaucracy is the branch we have to push on?
Also, accordingly, we have to open the PR in both repo jywarren/woofmark and bevacqua/woofmark?

@jywarren
Copy link
Owner

My apologies for not seeing this earlier! OK - so i pointed this at plots2 branch, and in my comment you referenced, the xhrOptions... branch is not necessary anymore!

Now, that was Oct 25, 2016, but we see that the change it refers to this upstream change in 2017: bevacqua#44 which was merged! So, haha, this is no longer necessary, and we can be building off woofmark v4.2.5 or maybe even v4.2.6, released in 2019.

So we can point the Editor directly at the plots2 branch. Hope that makes sense!

@jywarren jywarren changed the title Drag and drop css Refine drag and drop events to prevent interference with other drag/drop-sensitive fields in downstream use cases Jun 23, 2020
@jywarren
Copy link
Owner

Also I expanded on the title quite a bit to make it very clear what it achieves. Hope that makes sense!!!

@jywarren jywarren merged commit 75587c9 into jywarren:plots2 Jun 23, 2020
@jywarren
Copy link
Owner

Great! Looking good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants