(tooltipPoint, size, options)
| 755 | } |
| 756 | |
| 757 | getCaretPosition(tooltipPoint, size, options) { |
| 758 | const {xAlign, yAlign} = this; |
| 759 | const {caretSize, cornerRadius} = options; |
| 760 | const {topLeft, topRight, bottomLeft, bottomRight} = toTRBLCorners(cornerRadius); |
| 761 | const {x: ptX, y: ptY} = tooltipPoint; |
| 762 | const {width, height} = size; |
| 763 | let x1, x2, x3, y1, y2, y3; |
| 764 | |
| 765 | if (yAlign === 'center') { |
| 766 | y2 = ptY + (height / 2); |
| 767 | |
| 768 | if (xAlign === 'left') { |
| 769 | x1 = ptX; |
| 770 | x2 = x1 - caretSize; |
| 771 | |
| 772 | // Left draws bottom -> top, this y1 is on the bottom |
| 773 | y1 = y2 + caretSize; |
| 774 | y3 = y2 - caretSize; |
| 775 | } else { |
| 776 | x1 = ptX + width; |
| 777 | x2 = x1 + caretSize; |
| 778 | |
| 779 | // Right draws top -> bottom, thus y1 is on the top |
| 780 | y1 = y2 - caretSize; |
| 781 | y3 = y2 + caretSize; |
| 782 | } |
| 783 | |
| 784 | x3 = x1; |
| 785 | } else { |
| 786 | if (xAlign === 'left') { |
| 787 | x2 = ptX + Math.max(topLeft, bottomLeft) + (caretSize); |
| 788 | } else if (xAlign === 'right') { |
| 789 | x2 = ptX + width - Math.max(topRight, bottomRight) - caretSize; |
| 790 | } else { |
| 791 | x2 = this.caretX; |
| 792 | } |
| 793 | |
| 794 | if (yAlign === 'top') { |
| 795 | y1 = ptY; |
| 796 | y2 = y1 - caretSize; |
| 797 | |
| 798 | // Top draws left -> right, thus x1 is on the left |
| 799 | x1 = x2 - caretSize; |
| 800 | x3 = x2 + caretSize; |
| 801 | } else { |
| 802 | y1 = ptY + height; |
| 803 | y2 = y1 + caretSize; |
| 804 | |
| 805 | // Bottom draws right -> left, thus x1 is on the right |
| 806 | x1 = x2 + caretSize; |
| 807 | x3 = x2 - caretSize; |
| 808 | } |
| 809 | y3 = y1; |
| 810 | } |
| 811 | return {x1, x2, x3, y1, y2, y3}; |
| 812 | } |
| 813 | |
| 814 | drawTitle(pt, ctx, options) { |
no test coverage detected