(ctx)
| 1038 | } |
| 1039 | |
| 1040 | draw(ctx) { |
| 1041 | const options = this.options.setContext(this.getContext()); |
| 1042 | let opacity = this.opacity; |
| 1043 | |
| 1044 | if (!opacity) { |
| 1045 | return; |
| 1046 | } |
| 1047 | |
| 1048 | this._updateAnimationTarget(options); |
| 1049 | |
| 1050 | const tooltipSize = { |
| 1051 | width: this.width, |
| 1052 | height: this.height |
| 1053 | }; |
| 1054 | const pt = { |
| 1055 | x: this.x, |
| 1056 | y: this.y |
| 1057 | }; |
| 1058 | |
| 1059 | class="cm">// IE11/Edge does not like very small opacities, so snap to 0 |
| 1060 | opacity = Math.abs(opacity) < 1e-3 ? 0 : opacity; |
| 1061 | |
| 1062 | const padding = toPadding(options.padding); |
| 1063 | |
| 1064 | class="cm">// Truthy/falsey value for empty tooltip |
| 1065 | const hasTooltipContent = this.title.length || this.beforeBody.length || this.body.length || this.afterBody.length || this.footer.length; |
| 1066 | |
| 1067 | if (options.enabled && hasTooltipContent) { |
| 1068 | ctx.save(); |
| 1069 | ctx.globalAlpha = opacity; |
| 1070 | |
| 1071 | class="cm">// Draw Background |
| 1072 | this.drawBackground(pt, ctx, tooltipSize, options); |
| 1073 | |
| 1074 | overrideTextDirection(ctx, options.textDirection); |
| 1075 | |
| 1076 | pt.y += padding.top; |
| 1077 | |
| 1078 | class="cm">// Titles |
| 1079 | this.drawTitle(pt, ctx, options); |
| 1080 | |
| 1081 | class="cm">// Body |
| 1082 | this.drawBody(pt, ctx, options); |
| 1083 | |
| 1084 | class="cm">// Footer |
| 1085 | this.drawFooter(pt, ctx, options); |
| 1086 | |
| 1087 | restoreTextDirection(ctx, options.textDirection); |
| 1088 | |
| 1089 | ctx.restore(); |
| 1090 | } |
| 1091 | } |
| 1092 | |
| 1093 | /** |
| 1094 | * Get active elements in the tooltip |
nothing calls this directly
no test coverage detected