-
I would like to make a component draggable. According to issue #710 the following code Editor.on('component:selected', () => {
const selectedComponent = Editor.getSelected()
if (selectedComponent.get('draggable') == true) {
let selectedElement = selectedComponent.view.el
selectedElement._hasCustomEvent = 1
selectedElement.addEventListener(
'mousedown', (Event) => {
console.log('moving',selectedElement)
Editor.runCommand('tlb-move', { event:Event })
}
)
}
}) should work, but it doesn't (although console output shows that The component's block has been defined with model: {
defaults: {
resizable: true,
draggable: true, Is there anything else I should consider in order to make a component moveable by dragging? |
Beta Was this translation helpful? Give feedback.
Answered by
rozek
Aug 26, 2023
Replies: 1 comment
-
Ok, I found the solution - although it wasn't obvious: Simply add let Editor = grapesjs.init({
dragMode:'absolute',
...
}) and you're done! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rozek
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, I found the solution - although it wasn't obvious:
Simply add
dragMode:'absolute',
tograpesjs.init
like so:and you're done!