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
Make an entire element draggable, not just the handle #710
Comments
Try with something like this editor.on('component:selected', () => {
const selected = editor.getSelected();
if (!selected || !selected.get('draggable')) return;
const el = selected.view.el;
if (!el._hasCustomEvent) {
el._hasCustomEvent = 1;
el.addEventListener('mousedown', () => { editor.runCommand('tlb-move') })
}
}); |
I followed your suggestion, but I get an error: "Uncaught TypeError: Cannot read property 'type' of undefined"
If I click once on a component the console log is executed saying "should work", but if I drag, I get the error. Any further suggestions? |
Thanks so much for the update! I'm still a bit struggling to implement it right. I made an example: The example is preventing the user from doing too much. Most of the elements are made non-draggable. The user should be able to reorder.
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm working on modifying the handle from draggable elements, in addition to having a handle, I'd like the entire element to be draggable. Looking through the code, I would assume I would just need to attach the
tlb-move
command to a draggable element on select.The above code, on select, writes the selected component to the console. From here I believe I would need to add an event listener for dragging, however, my attempts to attach a listener using
.on()
have failed. Any advice on how to attach an event listener to a select component?The text was updated successfully, but these errors were encountered: