0.0.4 • Published 5 years ago

ember-drag-drop-multiple v0.0.4

Weekly downloads
16
License
MIT
Repository
github
Last release
5 years ago

ember-drag-drop-multiple

npm version Ember Observer Score Build Status Code Climate

Description

This Ember Addon exposes a component adding multiple selection functionalities to ember-drag-drop

Installation

  • ember install ember-drag-drop-multiple

Docs

Dragging multiple objects

TODO

Here's an example of how that would be accomplished:

{{#draggable-object-target action=(action 'increaseRating')}}
  Drag here to increase rating
{{/draggable-object-target}}

<br>

{{#selectable-objects as |so|}}
  {{#each model as |post|}}
    {{#so.object content=post}}
      {{post.title}} [ Rating: {{post.rating}} ]
    {{/so.object}}
  {{/each}}
{{/selectable-objects}}
import Ember from 'ember';

const { Controller, isArray } = Ember;

export default Controller.extend({
  actions: {
    increaseRating(payload, options) {
      if (isArray(payload)) {
        payload.map(post => post.incrementProperty('rating', 1));
      } else {
        payload.incrementProperty('rating', 1);
      }
    }
  }
});

Change the drag image

If you wish to change the style of your draggable-object when it's being dragged, simply provide an element selector using the dragImageSelector property and the element will be set as the drag image.

{{#draggable-object dragImageSelector=".drag-image"}}
    Drag Me
{{/draggable-object}}

<div class="drag-image">Drag Image</div>

License

This project is licensed under the MIT License.