Skip to content

Instantly share code, notes, and snippets.

@matt-morris
Last active January 23, 2019 00:11
Show Gist options
  • Save matt-morris/c0dd19c73a02bc2323bcb6c33fb1825e to your computer and use it in GitHub Desktop.
Save matt-morris/c0dd19c73a02bc2323bcb6c33fb1825e to your computer and use it in GitHub Desktop.
Drag and Drop Components
import Ember from 'ember';
export default Ember.Component.extend({
draggable: true,
attributeBindings: ['draggable'],
classNames: ['p-4 border'],
dragEnd() {
alert("the drag ended")
},
});
import Ember from 'ember';
export default Ember.Component.extend({
droppable: true,
attributeBindings: ['droppable'],
classNames: ['p-4 border'],
dragEnter(e) {
alert("dragEnter")
e.preventDefault()
e.stopPropagation()
},
dragOver(e) {
alert("dragOver")
e.preventDefault()
e.stopPropagation()
},
drop(e) {
alert("drop")
e.preventDefault()
e.stopPropagation()
},
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.border {
border: 1px solid grey;
}
.p-4 {
padding: 1rem;
}
<DraggableItem>
[ drag me, drop me ]
</DraggableItem>
<DropZone>
[ lay it on me ]
</DropZone>
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment