102 lines
3.1 KiB
JavaScript
102 lines
3.1 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
exports.default = createTargetMonitor;
|
|
|
|
var _invariant = require('invariant');
|
|
|
|
var _invariant2 = _interopRequireDefault(_invariant);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var isCallingCanDrop = false;
|
|
|
|
var TargetMonitor = function () {
|
|
function TargetMonitor(manager) {
|
|
_classCallCheck(this, TargetMonitor);
|
|
|
|
this.internalMonitor = manager.getMonitor();
|
|
}
|
|
|
|
_createClass(TargetMonitor, [{
|
|
key: 'receiveHandlerId',
|
|
value: function receiveHandlerId(targetId) {
|
|
this.targetId = targetId;
|
|
}
|
|
}, {
|
|
key: 'canDrop',
|
|
value: function canDrop() {
|
|
(0, _invariant2.default)(!isCallingCanDrop, 'You may not call monitor.canDrop() inside your canDrop() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs-drop-target-monitor.html');
|
|
|
|
try {
|
|
isCallingCanDrop = true;
|
|
return this.internalMonitor.canDropOnTarget(this.targetId);
|
|
} finally {
|
|
isCallingCanDrop = false;
|
|
}
|
|
}
|
|
}, {
|
|
key: 'isOver',
|
|
value: function isOver(options) {
|
|
return this.internalMonitor.isOverTarget(this.targetId, options);
|
|
}
|
|
}, {
|
|
key: 'getItemType',
|
|
value: function getItemType() {
|
|
return this.internalMonitor.getItemType();
|
|
}
|
|
}, {
|
|
key: 'getItem',
|
|
value: function getItem() {
|
|
return this.internalMonitor.getItem();
|
|
}
|
|
}, {
|
|
key: 'getDropResult',
|
|
value: function getDropResult() {
|
|
return this.internalMonitor.getDropResult();
|
|
}
|
|
}, {
|
|
key: 'didDrop',
|
|
value: function didDrop() {
|
|
return this.internalMonitor.didDrop();
|
|
}
|
|
}, {
|
|
key: 'getInitialClientOffset',
|
|
value: function getInitialClientOffset() {
|
|
return this.internalMonitor.getInitialClientOffset();
|
|
}
|
|
}, {
|
|
key: 'getInitialSourceClientOffset',
|
|
value: function getInitialSourceClientOffset() {
|
|
return this.internalMonitor.getInitialSourceClientOffset();
|
|
}
|
|
}, {
|
|
key: 'getSourceClientOffset',
|
|
value: function getSourceClientOffset() {
|
|
return this.internalMonitor.getSourceClientOffset();
|
|
}
|
|
}, {
|
|
key: 'getClientOffset',
|
|
value: function getClientOffset() {
|
|
return this.internalMonitor.getClientOffset();
|
|
}
|
|
}, {
|
|
key: 'getDifferenceFromInitialOffset',
|
|
value: function getDifferenceFromInitialOffset() {
|
|
return this.internalMonitor.getDifferenceFromInitialOffset();
|
|
}
|
|
}]);
|
|
|
|
return TargetMonitor;
|
|
}();
|
|
|
|
function createTargetMonitor(manager) {
|
|
return new TargetMonitor(manager);
|
|
} |