Draggable: confused about the usage of Droppable

Created on 1 Aug 2018  路  2Comments  路  Source: Shopify/draggable

I was confused about the usage of Droppable.
Why this code doesn't work as the example does?

import { Droppable } from '@shopify/draggable'

const drop = new Droppable(document.querySelectorAll('.container'), {
  draggable: '.draggable',
  dropzone: '#dropzone'
})
  <div class="container">
    <div class="item">

    </div>
  </div>

  <div class="container">
    <div id="dropzone"></div>
  </div>
documentation question

Most helpful comment

@beefchimi Thanks for your patient. Your answer helps me a lot!!!
Again, Thank you.

But i have to say, the documentation of Draggable is sometimes quiet confusing. Maybe it just because there is no relative code of html and stylesheet. But i dare to say it won't help unless you clearly mention of that in the documentation and examples.

If possible, i think i may could contribute to the work of documentation and translation.

Again, thanks for your help.

All 2 comments

Droppable docs still have not received the love they require... so apologies for this being a bit mysterious.

What is most likely the issue is:

  • Your item needs to also originate from a Dropzone
  • That origin Dropzone needs to specify that it is "occupied" on page load, by way of a specific classname _(classes can be customized)_

To start, I would trouble shoot by changing the following:

JS

import { Droppable } from '@shopify/draggable'

const drop = new Droppable(document.querySelectorAll('.container'), {
  draggable: '.item-to-drag',
  dropzone: '.dropzone',
});

HTML

<section class="container container--1">
  <article class="dropzone dropzone--1 draggable-droppable--occupied">
    <h6>This is an occupied dropzone</h6>

    <div class="item-to-drag">
      <p>Plz drag me</p>
    </div>
  </article>
</section>

<section class="container container--2">
  <article class="dropzone dropzone--2">
    <h6>Waiting to recieve a draggable source...</h6>
  </article>
</section>

For more info, I recommend checking out the Droppable example, as well as its source code.

Give that a shot and let us know what happens.

Cheers!

@beefchimi Thanks for your patient. Your answer helps me a lot!!!
Again, Thank you.

But i have to say, the documentation of Draggable is sometimes quiet confusing. Maybe it just because there is no relative code of html and stylesheet. But i dare to say it won't help unless you clearly mention of that in the documentation and examples.

If possible, i think i may could contribute to the work of documentation and translation.

Again, thanks for your help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

890f2151c2be69c51db72017546d00fd picture 890f2151c2be69c51db72017546d00fd  路  4Comments

indirectlylit picture indirectlylit  路  3Comments

pumpknhd picture pumpknhd  路  4Comments

decademoon picture decademoon  路  4Comments

asmith26 picture asmith26  路  3Comments