UNPKG

vue3-dnd

Version:

Drag and Drop for Vue Composition API

81 lines (80 loc) 3.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DropTargetMonitorImpl = void 0; var _invariant = require("@react-dnd/invariant"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var isCallingCanDrop = false; var DropTargetMonitorImpl = /*#__PURE__*/ function() { "use strict"; function DropTargetMonitorImpl(manager) { _classCallCheck(this, DropTargetMonitorImpl); this.targetId = null; this.internalMonitor = manager.getMonitor(); } var _proto = DropTargetMonitorImpl.prototype; _proto.receiveHandlerId = function receiveHandlerId(targetId) { this.targetId = targetId; }; _proto.getHandlerId = function getHandlerId() { return this.targetId; }; _proto.subscribeToStateChange = function subscribeToStateChange(listener, options) { return this.internalMonitor.subscribeToStateChange(listener, options); }; _proto.canDrop = function canDrop() { // Cut out early if the target id has not been set. This should prevent errors // where the user has an older version of dnd-core like in // https://github.com/react-dnd/react-dnd/issues/1310 if (!this.targetId) { return false; } (0, _invariant).invariant(!isCallingCanDrop, "You may not call monitor.canDrop() inside your canDrop() implementation. " + "Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor"); try { isCallingCanDrop = true; return this.internalMonitor.canDropOnTarget(this.targetId); } finally{ isCallingCanDrop = false; } }; _proto.isOver = function isOver(options) { if (!this.targetId) { return false; } return this.internalMonitor.isOverTarget(this.targetId, options); }; _proto.getItemType = function getItemType() { return this.internalMonitor.getItemType(); }; _proto.getItem = function getItem() { return this.internalMonitor.getItem(); }; _proto.getDropResult = function getDropResult() { return this.internalMonitor.getDropResult(); }; _proto.didDrop = function didDrop() { return this.internalMonitor.didDrop(); }; _proto.getInitialClientOffset = function getInitialClientOffset() { return this.internalMonitor.getInitialClientOffset(); }; _proto.getInitialSourceClientOffset = function getInitialSourceClientOffset() { return this.internalMonitor.getInitialSourceClientOffset(); }; _proto.getSourceClientOffset = function getSourceClientOffset() { return this.internalMonitor.getSourceClientOffset(); }; _proto.getClientOffset = function getClientOffset() { return this.internalMonitor.getClientOffset(); }; _proto.getDifferenceFromInitialOffset = function getDifferenceFromInitialOffset() { return this.internalMonitor.getDifferenceFromInitialOffset(); }; return DropTargetMonitorImpl; }(); exports.DropTargetMonitorImpl = DropTargetMonitorImpl;