(tooltipPoint, size, options)
| 697 | } |
| 698 | |
| 699 | getCaretPosition(tooltipPoint, size, options) { |
| 700 | const {xAlign, yAlign} = this; |
| 701 | const {caretSize, cornerRadius} = options; |
| 702 | const {topLeft, topRight, bottomLeft, bottomRight} = toTRBLCorners(cornerRadius); |
| 703 | const {x: ptX, y: ptY} = tooltipPoint; |
| 704 | const {width, height} = size; |
| 705 | let x1, x2, x3, y1, y2, y3; |
| 706 | |
| 707 | if (yAlign === 'center') { |
| 708 | y2 = ptY + (height / 2); |
| 709 | |
| 710 | if (xAlign === 'left') { |
| 711 | x1 = ptX; |
| 712 | x2 = x1 - caretSize; |
| 713 | |
| 714 | // Left draws bottom -> top, this y1 is on the bottom |
| 715 | y1 = y2 + caretSize; |
| 716 | y3 = y2 - caretSize; |
| 717 | } else { |
| 718 | x1 = ptX + width; |
| 719 | x2 = x1 + caretSize; |
| 720 | |
| 721 | // Right draws top -> bottom, thus y1 is on the top |
| 722 | y1 = y2 - caretSize; |
| 723 | y3 = y2 + caretSize; |
| 724 | } |
| 725 | |
| 726 | x3 = x1; |
| 727 | } else { |
| 728 | if (xAlign === 'left') { |
| 729 | x2 = ptX + Math.max(topLeft, bottomLeft) + (caretSize); |
| 730 | } else if (xAlign === 'right') { |
| 731 | x2 = ptX + width - Math.max(topRight, bottomRight) - caretSize; |
| 732 | } else { |
| 733 | x2 = this.caretX; |
| 734 | } |
| 735 | |
| 736 | if (yAlign === 'top') { |
| 737 | y1 = ptY; |
| 738 | y2 = y1 - caretSize; |
| 739 | |
| 740 | // Top draws left -> right, thus x1 is on the left |
| 741 | x1 = x2 - caretSize; |
| 742 | x3 = x2 + caretSize; |
| 743 | } else { |
| 744 | y1 = ptY + height; |
| 745 | y2 = y1 + caretSize; |
| 746 | |
| 747 | // Bottom draws right -> left, thus x1 is on the right |
| 748 | x1 = x2 + caretSize; |
| 749 | x3 = x2 - caretSize; |
| 750 | } |
| 751 | y3 = y1; |
| 752 | } |
| 753 | return {x1, x2, x3, y1, y2, y3}; |
| 754 | } |
| 755 | |
| 756 | drawTitle(pt, ctx, options) { |
no test coverage detected