export default { name:'GridItem', components: { }, inject: { }, props: { item: Object, active: Boolean }, emits: [ "mouseDown", "mouseUp", "startMove", "startResize", "dragging", "endDrag", "dropDrag", "item", "touchStart", "touchEnd", ], data() { return { dragAction: '', dragging: false } }, computed: { }, methods: { registerDragAction(evt) { this.$emit('mouseDown', evt); if (evt.target.hasAttribute('drag-action')) { this.dragAction = evt.target.getAttribute('drag-action'); } else { let parent = evt.target.closest('[drag-action]'); if (parent) { this.dragAction = parent.getAttribute('drag-action'); } else { this.dragAction = ''; } } }, tryDragStart(evt, item) { let dragAction = this.dragAction || evt.target.getAttribute('drag-action'); if (dragAction) { this.dragging = true; if (dragAction == 'move') return this.$emit('startMove', evt, item); else if (dragAction == 'resize') return this.$emit('startResize', evt, item); } //evt.preventDefault(); }, touchDragEnd(evt) { if (!this.dragging) return; this.dragging = false; this.$emit('touchEnd', evt); }, touchStart(event){ this.$emit('touchStart', event); this.registerDragAction(event); this.tryDragStart(event, this.item); }, touchMove(event){ if(this.dragging){ event.preventDefault(); this.$emit('dragging', event); } } }, template: `