var t = require; var e = module; var i = exports; var s, e = (this && this.__decorate) || function(t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }; Object.defineProperty(i, "__esModule", { value: !0 }), (i.DragEventType = void 0); const o = t("App"), { ccclass: a, menu: n } = cc._decorator; ((t = s = i.DragEventType || (i.DragEventType = {})).DRAG_START = "DRAG_START"), (t.DRAGING = "DRAGING"), (t.DRAGING_IN = "DRAGING_IN"), (t.DRAGING_OUT = "DRAGING_OUT"), (t.DROP = "DROP"), (t.CANCEL = "CANCEL"), (t.DRAG_END = "DRAG_END"); (t = class extends cc.Component { constructor() { super(...arguments), (this.delegate = { onDragStart: function() { return null; }, onDragEnd: function() { return null; }, onDragDone: function() { return null; }, prepareDrag: function() { return { dragingData: null, dragingNode: null }; } }); } start() {} onEnable() { this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this); } onDisable() { this.node.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this); } setDelegate(t) { this.delegate = t; } onDragDone(t, e) { this.delegate.onDragDone && this.delegate.onDragDone(this.dragingData, e); } onTouchStart(t) { var e = this.delegate.prepareDrag(); e && ((this.dragingData = e.dragingData), (this.dragingNode = e.dragingNode), this.node.emit(s.DRAG_START, this, this.dragingData), (e = o.default.ViewManager.uiRoot).emit(s.DRAG_START, this, this.dragingData), e.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this, !0), e.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this, !0), e.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this, !0), this.delegate.onDragStart(this.dragingData), this.dragingNode && ((this.dragingNode.position = e.convertToNodeSpaceAR(t.getLocation())), e.addChild(this.dragingNode))); } onTouchMove(t) { var e; this.node.emit(s.DRAGING, this, this.dragingData), this.dragingNode && ((e = o.default.ViewManager.uiRoot), (this.dragingNode.position = e.convertToNodeSpaceAR(t.getLocation()))); } onTouchEnd(t) { this.delegate.onDragEnd && this.delegate.onDragEnd(this.dragingData), this.dragingNode && this.dragingNode.removeFromParent(), this.node.emit(s.DRAG_END, this, this.dragingData), o.default.ViewManager.uiRoot.emit(s.DRAG_END, this, this.dragingData, t), o.default.ViewManager.uiRoot.targetOff(this); } }), (t = e([a], t)); i.default = t;