Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

correct tooltip positioning for dx and dy #286

Merged
merged 1 commit into from
Aug 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/victory-tooltip/victory-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,13 @@ export default class VictoryTooltip extends React.Component {
getFlyoutCenter(props, dimensions) {
const { x, y, dx, dy, pointerLength, orientation } = props;
const { height, width } = dimensions;
const sign = orientation === "right" || orientation === "top" ? 1 : -1;
const xSign = orientation === "left" ? -1 : 1;
const ySign = orientation === "bottom" ? -1 : 1;
return {
x: orientation === "left" || orientation === "right" ?
x + sign * (pointerLength + (width / 2) + dx) : x + sign * dx,
x + xSign * (pointerLength + (width / 2) + dx) : x + dx,
y: orientation === "top" || orientation === "bottom" ?
y - sign * (pointerLength + (height / 2) + dy) : y - sign * dy
y - ySign * (pointerLength + (height / 2) + dy) : y - dy
};
}

Expand Down