ember-drag-drop icon indicating copy to clipboard operation
ember-drag-drop copied to clipboard

{{draggable-object}} as a component mixin

Open archseer opened this issue 9 years ago • 6 comments

It would be nice if {{draggable-object}} was available as a component mixin, my specific usecase is as follows: I have a track-item component that I render inside an each block, and I wanted to make it drag 'n droppable. I ended up wrapping the entire template:

// templates/components/track-item.js
{{#draggable-object content=track}}
// my track component template here
{{/draggable-object}}

Problem is, the DOM structure now nested:

<li class="ember-view track" id="ember683">
  <div class="ember-view js-draggableObject draggable-object" draggable="true" id="ember684">  
    <!-- ... -->
  </div>
</li>

The styling is now broken, because it wasn't expecting the extra object. Admittedly, I can just tweak the CSS (which is what I did), but it would be nice to get rid of the extra wrapper.

archseer avatar Dec 20 '15 16:12 archseer

It's a thought for sure, I'll see what I can do to support it. In the mean time to clean up your DOM structure you could pass in a tagName='span' in the {{draggable-object}} component as a span wouldn't mess with the layout nearly as much as a div might in this instance.

dgavey avatar Dec 22 '15 21:12 dgavey

Short term, couldn't you just extend your component from the draggableObject rather than using it as a mixin? @archSeer

lcpriest avatar Feb 08 '16 03:02 lcpriest

I can confirm that extending draggableObject does the trick:

import DraggableObject from 'ember-drag-drop/components/draggable-object';

export default DraggableObject.extend(...

sbsurf avatar Apr 18 '16 17:04 sbsurf

thanks @sbsurf for the example, this is pretty much as good as a mixin I think.

dgavey avatar Apr 18 '16 20:04 dgavey

would the same thing be possible with draggable-object-target?

yankeeinlondon avatar Aug 25 '16 22:08 yankeeinlondon

@ksnyde You could easily extend the draggable-object-target as well.

dgavey avatar Aug 28 '16 02:08 dgavey