placements.js
2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import _extends from "@babel/runtime/helpers/extends";
import { placements } from "rc-tooltip/es/placements";
var autoAdjustOverflowEnabled = {
adjustX: 1,
adjustY: 1
};
var autoAdjustOverflowDisabled = {
adjustX: 0,
adjustY: 0
};
var targetOffset = [0, 0];
export function getOverflowOptions(autoAdjustOverflow) {
if (typeof autoAdjustOverflow === 'boolean') {
return autoAdjustOverflow ? autoAdjustOverflowEnabled : autoAdjustOverflowDisabled;
}
return _extends(_extends({}, autoAdjustOverflowDisabled), autoAdjustOverflow);
}
export default function getPlacements(config) {
var _config$arrowWidth = config.arrowWidth,
arrowWidth = _config$arrowWidth === void 0 ? 5 : _config$arrowWidth,
_config$horizontalArr = config.horizontalArrowShift,
horizontalArrowShift = _config$horizontalArr === void 0 ? 16 : _config$horizontalArr,
_config$verticalArrow = config.verticalArrowShift,
verticalArrowShift = _config$verticalArrow === void 0 ? 8 : _config$verticalArrow,
autoAdjustOverflow = config.autoAdjustOverflow;
var 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(function (key) {
placementMap[key] = config.arrowPointAtCenter ? _extends(_extends({}, placementMap[key]), {
overflow: getOverflowOptions(autoAdjustOverflow),
targetOffset: targetOffset
}) : _extends(_extends({}, placements[key]), {
overflow: getOverflowOptions(autoAdjustOverflow)
});
placementMap[key].ignoreShake = true;
});
return placementMap;
}