-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add dragover event #4406
Comments
is an easy implementation and we should add it. |
@asturur Looked at the implementation, tweaked it a little to get it to work. Almost what I was looking for but it doesn't fire for objects in the canvas. Found the __onMouseMove & _fireOverOutEvents implementation which seems to be what I'm looking for but for onDrag. Added the following function as seen below. onDragEnter & onDragLeave now triggeres for both canvas and objects if events are applied directly to the canvas. Tho if the events are applied on an object nothing is fired... Any thoughts? `
` |
yes apart i noticed i left some error around, i do not want to support drag enter and drag leave on a per object basis. All the events (apart dragEnter and dragLeave) should be already working on a per object basis ( dragOver and drop basically ) while for enter and leave we need to do something like you did. After that initial sketch i did not have time to iterate over. |
Will you have time to do this implementation or will I have to be the one? Not sure of the requirements and how the code works, I guess I could give it a try. So a combination or your implementation and mine but without the mouse: prefix? |
no worries i think i can fix it and merge the one without enter/leave today.
Please just take care of checking if the first draft will work as soon as i ping you. Do you know how to build the library from the command line to pick up latest ? |
Yes been using your feature branch and building with npm run build. yes just ping me and I'll try it out |
When I try the current code: The variable "targets" in the "_simpleEventHandler" function is always an empty array even when dragging over group objects in my canvas. |
Any progress on this since Oct? I haven't gotten to it yet, but I think I'm going to need this functionality for a project I'm working on. @asturur , regarding your comment above, "I do not want to support drag enter and drag leave on a per object basis". Could you go into more detail on what the rules are for fabric's event system? The docs explain how to work with events, but I still feel a little lost when trying to do certain things. For example, when handling events on collections of objects in the HTML DOM, I typically use event delegation, since events fired on a node are then fired all the way up the DOM tree. This doesn't appear to be possible in fabric. I assume this has to do with fabric being optimized for speed (we all know how slow the DOM can be.) |
well fabric is a unique dom element and all objects are just pixels over it. you drag something from outside the canvas and you will get the event, but internally in the canvas you cannot drag objects one over the other, no event will be fired for |
I did some changes and got it working. Not sure if I did something "bad", basically copied how it was done for mouse over, figured it would be the same. |
Hey i know a lot of time passed, i pushed on the webiste a demo version of it fabricjs.com/events looks like working i need to add some tests. |
Seems to be working as I originally thought! Thank you 🙏 |
I'm trying write an application to drag & drop html images onto the canvas. The problem with the current available events is that they won't fire when dragging an image over the canvas. If this event was supported it would be a lot easier to, for example, have an object in the canvas change it's appearance to let the user know that the image can be dropped onto the object.
Thx for a nice library 🙏🏼
The text was updated successfully, but these errors were encountered: