Skip to content

Commit

Permalink
New (breaking) action use
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarrough committed Oct 18, 2015
1 parent 4f43d08 commit e1b9f3e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[![Build Status](https://travis-ci.org/kalcifer/ember-dragula.svg?branch=master)](https://travis-ci.org/kalcifer/ember-dragula)
# Ember-dragula
# Ember Dragula

##Introduction
## Introduction

An ember addon that allows to use Dragula - A drag and drop library (https://github.com/bevacqua/dragula)

##How to use
## How to use

###Install addon

ember install ember-dragula

###Syntax
The following syntax is required to get the addon working.
```
{{#ember-dragula config=dragulaconfig dragulaEvent='dragulaEvent' }}
{{#ember-dragula config=dragulaconfig over='doSomethingOnOver' drag='doSomethingOnDrag'}}
{{#ember-dragula-container }}
<div>
...
Expand All @@ -30,25 +31,23 @@ The following syntax is required to get the addon working.
{{/ember-dragula-container}}
{{/ember-dragula}}
```

Since dragula uses containers whose elements we can drag and drop. So ```ember-dragula``` is the ember container for all dragula containers(including those defined in ```isContainer```. It is also the component that manages the lifecycle for the associated drake.

###Passing options

In the above code snippet, the config parameter must be in the following format.
```
'dragulaconfig':{
'options':{
copy: false,
revertOnSpill: false,
removeOnSpill: false
//Other options from the dragula source page.
},
'eventList':[{
name:'drag'
},{
name:'drop'
}]// all the events that you want to listen to. TBD - will make this simpler.
}

```js
dragulaconfig: {
options: {
copy: false,
revertOnSpill: false,
removeOnSpill: false
// Other options from the dragula source page.
},
enabledEvents: ['drag', 'drop']
}
```

## Installation
Expand Down
10 changes: 5 additions & 5 deletions addon/components/ember-dragula.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export default Component.extend({
}),

setEventListeners: on('didInsertElement', function () {
if (!this.config.eventList) {
if (!this.config.enabledEvents) {
return;
}
this.config.eventList.forEach(event => {
this.drake.on(event.name, function () {
this.sendAction('dragulaEvent', event.name, arguments);
}.bind(this));
this.config.enabledEvents.forEach(eventName => {
this.drake.on(eventName, (...args) => {
this.sendAction(eventName, args);
});
});
}),

Expand Down

0 comments on commit e1b9f3e

Please sign in to comment.