UNPKG

@atlaskit/pragmatic-drag-and-drop-hitbox

Version:

An optional package for Pragmatic drag and drop that enables the attaching of interaction information to a drop target

55 lines (51 loc) • 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "attachInstruction", { enumerable: true, get: function get() { return _attachInstruction.attachInstruction; } }); exports.axisLookup = void 0; Object.defineProperty(exports, "extractInstruction", { enumerable: true, get: function get() { return _extractInstruction.extractInstruction; } }); exports.reorder = reorder; exports.uniqueKey = void 0; var _attachInstruction = require("./attach-instruction-2"); var _extractInstruction = require("./extract-instruction-2"); // using a symbol so we can guarantee a key with a unique value var uniqueKey = exports.uniqueKey = Symbol('list-item-instruction'); var axisLookup = exports.axisLookup = { vertical: { start: 'top', end: 'bottom', size: 'height', point: 'y' }, horizontal: { start: 'left', end: 'right', size: 'width', point: 'x' } }; function reorder(_ref) { var client = _ref.client, borderBox = _ref.borderBox, axis = _ref.axis; var halfSize = borderBox[axis.size] / 2; // In the top 1/2: reorder-before // On the line: reorder-after to give a slight preference to moving forward if (client[axis.point] < borderBox[axis.start] + halfSize) { return 'reorder-before'; } return 'reorder-after'; } // eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Disabled via Volt Codemod. Do not add more exports to this file. // eslint-disable-next-line @atlaskit/volt-strict-mode/no-re-exports -- Disabled via Volt Codemod. Do not add more exports to this file.