Issue #2310💬 AnsweredOpened October 5, 2019by AbdallaMohammed1 reactions

How can I specify position for dragging elements ?

快速解答by pouyamiralayi1

i don't have components iam using blocks according to this: i have a div with id="drag-here" i assume your block is something like this: the approach for your container block would be: and for target blocks: cheers!

Read full answer below ↓

Question

Hi iam doing a project with this library and i want to specify position for dragging components in it for example i have a div with id="drag-here" i want all components to be dragged in this div only

i hope you can understand me , thank you all

Answers (3)

pouyamiralayiOctober 6, 2019

i don't have components iam using blocks

according to this:

i have a div with id="drag-here"

i assume your block is something like this:

content: '<div id="drag-here"></div>'

the approach for your container block would be:

editor.BlockManager.add('drag-here',{
    lablel:'Drag Here',
    content:'<div id="drag-here" data-gjs-droppable="true" style="width:100px;height:100px; background:red;"></div>'
})

and for target blocks:

editor.BlockManager.add('drop',{
    lablel:'Drop',
    content:'<div data-gjs-draggable="div#drag-here" style="width:50px;height:50px; background:blue;"></div>'
})

cheers!

pouyamiralayiOctober 5, 2019

i have a div with id="drag-here" i want all components to be dragged in this div only

if by this you mean you want all components to be draggable only in your target component, you can use draggable property. by specifying draggable on your components like this:

draggable: 'target, target *'

cheers!

AbdallaMohammedOctober 6, 2019

by specifying draggable on your components like this:

thank you for fast replay , but i don't have components iam using blocks

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.