vue3-dnd
Version:
Drag and Drop for Vue Composition API
57 lines (56 loc) • 1.87 kB
JavaScript
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
export var DragSourceImpl = /*#__PURE__*/ function() {
"use strict";
function DragSourceImpl(spec, monitor, connector) {
_classCallCheck(this, DragSourceImpl);
this.spec = spec;
this.monitor = monitor;
this.connector = connector;
}
var _proto = DragSourceImpl.prototype;
_proto.beginDrag = function beginDrag() {
var spec = this.spec;
var monitor = this.monitor;
var result = null;
if (typeof spec.item === "object") {
result = spec.item;
} else if (typeof spec.item === "function") {
result = spec.item(monitor);
} else {
result = {};
}
return result !== null && result !== void 0 ? result : null;
};
_proto.canDrag = function canDrag() {
var spec = this.spec;
var monitor = this.monitor;
if (typeof spec.canDrag === "boolean") {
return spec.canDrag;
} else if (typeof spec.canDrag === "function") {
return spec.canDrag(monitor);
} else {
return true;
}
};
_proto.isDragging = function isDragging(globalMonitor, target) {
var spec = this.spec;
var monitor = this.monitor;
var isDragging1 = spec.isDragging;
return isDragging1 ? isDragging1(monitor) : target === globalMonitor.getSourceId();
};
_proto.endDrag = function endDrag() {
var spec = this.spec;
var monitor = this.monitor;
var connector = this.connector;
var end = spec.end;
if (end) {
end(monitor.getItem(), monitor);
}
connector.reconnect();
};
return DragSourceImpl;
}();