| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- "use strict";
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = getPlacements;
- exports.getOverflowOptions = getOverflowOptions;
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
- var _placements = require("../vc-tooltip/src/placements");
- const autoAdjustOverflowEnabled = {
- adjustX: 1,
- adjustY: 1
- };
- const autoAdjustOverflowDisabled = {
- adjustX: 0,
- adjustY: 0
- };
- const targetOffset = [0, 0];
- function getOverflowOptions(autoAdjustOverflow) {
- if (typeof autoAdjustOverflow === 'boolean') {
- return autoAdjustOverflow ? autoAdjustOverflowEnabled : autoAdjustOverflowDisabled;
- }
- return (0, _extends2.default)((0, _extends2.default)({}, autoAdjustOverflowDisabled), autoAdjustOverflow);
- }
- function getPlacements(config) {
- const {
- arrowWidth = 4,
- horizontalArrowShift = 16,
- verticalArrowShift = 8,
- autoAdjustOverflow,
- arrowPointAtCenter
- } = config;
- const placementMap = {
- left: {
- points: ['cr', 'cl'],
- offset: [-4, 0]
- },
- right: {
- points: ['cl', 'cr'],
- offset: [4, 0]
- },
- top: {
- points: ['bc', 'tc'],
- offset: [0, -4]
- },
- bottom: {
- points: ['tc', 'bc'],
- offset: [0, 4]
- },
- topLeft: {
- points: ['bl', 'tc'],
- offset: [-(horizontalArrowShift + arrowWidth), -4]
- },
- leftTop: {
- points: ['tr', 'cl'],
- offset: [-4, -(verticalArrowShift + arrowWidth)]
- },
- topRight: {
- points: ['br', 'tc'],
- offset: [horizontalArrowShift + arrowWidth, -4]
- },
- rightTop: {
- points: ['tl', 'cr'],
- offset: [4, -(verticalArrowShift + arrowWidth)]
- },
- bottomRight: {
- points: ['tr', 'bc'],
- offset: [horizontalArrowShift + arrowWidth, 4]
- },
- rightBottom: {
- points: ['bl', 'cr'],
- offset: [4, verticalArrowShift + arrowWidth]
- },
- bottomLeft: {
- points: ['tl', 'bc'],
- offset: [-(horizontalArrowShift + arrowWidth), 4]
- },
- leftBottom: {
- points: ['br', 'cl'],
- offset: [-4, verticalArrowShift + arrowWidth]
- }
- };
- Object.keys(placementMap).forEach(key => {
- placementMap[key] = arrowPointAtCenter ? (0, _extends2.default)((0, _extends2.default)({}, placementMap[key]), {
- overflow: getOverflowOptions(autoAdjustOverflow),
- targetOffset
- }) : (0, _extends2.default)((0, _extends2.default)({}, _placements.placements[key]), {
- overflow: getOverflowOptions(autoAdjustOverflow)
- });
- placementMap[key].ignoreShake = true;
- });
- return placementMap;
- }
|