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

feat(): drop:before event #7442

Merged
merged 4 commits into from
Jan 9, 2022
Merged

Conversation

ShaMan123
Copy link
Contributor

No description provided.

@asturur
Copy link
Member

asturur commented Oct 19, 2021

wait, which is the difference between drop:before and drop at this point?
if you register more than one drop:before event you have the exact same issue that with the drop event.

I m not opposed to this at all, just i want to understand better.

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Oct 19, 2021

The idea is to use drop:before on objects, perform logic and decide if to block the canvas from handling the drop as well.
We can fire the drop event first on the target before firing canvas but it is out of norm as far as the other events

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Oct 19, 2021

For example

        obj.on('drop:before', (opt) => {
            let handled = false;
            // logic mutating `handled`
            handled && opt.e.preventDefault();
        })

        canvas.on('drop', (opt) => {
            if (opt.e.defaultPrevented) return;
            //  handle the drop
        })

@ShaMan123
Copy link
Contributor Author

Another use case would be handling drop on objects in a different order than object stack order

@stale
Copy link

stale bot commented Nov 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label Nov 3, 2021
@stale stale bot closed this Nov 10, 2021
@ShaMan123 ShaMan123 reopened this Nov 15, 2021
@stale stale bot removed the stale Issue marked as stale by the stale bot label Nov 15, 2021
@stale
Copy link

stale bot commented Nov 30, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label Nov 30, 2021
@stale stale bot closed this Dec 7, 2021
@ShaMan123 ShaMan123 reopened this Dec 13, 2021
@stale stale bot removed the stale Issue marked as stale by the stale bot label Dec 13, 2021
@stale
Copy link

stale bot commented Dec 28, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label Dec 28, 2021
@stale stale bot closed this Jan 6, 2022
@ShaMan123 ShaMan123 removed the stale Issue marked as stale by the stale bot label Jan 6, 2022
@ShaMan123 ShaMan123 reopened this Jan 6, 2022
@asturur asturur added the feature label Jan 9, 2022
@asturur
Copy link
Member

asturur commented Jan 9, 2022

Sorry i m late on this.
Ok i m not super into this, but is not bad.
I will change the comment and merge it.

@asturur
Copy link
Member

asturur commented Jan 9, 2022

that object you set the drop:before event on, could be the object that is in the target of the normal drop event.
I understand that sometimes we don't want to have big even thandlers that take care of everything in a single function.

@asturur asturur merged commit 176a4e9 into fabricjs:master Jan 9, 2022
@ShaMan123 ShaMan123 deleted the drop-before-event branch January 9, 2022 22:18
rockerBOO pushed a commit to rockerBOO/fabric.js that referenced this pull request Jan 12, 2022
@asturur asturur mentioned this pull request Jan 26, 2022
rockerBOO pushed a commit to rockerBOO/fabric.js that referenced this pull request May 2, 2022
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 this pull request may close these issues.

2 participants