Files
graphfx/ui/Components/Drag/Draggable.js
2019-01-21 20:39:56 +01:00

24 lines
459 B
JavaScript

import interact from 'interactjs';
export default {
abstract: true,
render() {
try {
return this.$slots.default[0];
} catch (e) {
throw new Error('Exactly one child component needed.');
}
return null;
},
mounted () {
const el = this.$slots.default[0].elm;
this.$nextTick(() => {
interact(el)
.draggable({
onmove: (event) => {
this.$emit('move', event);
}
})
})
}
}