@@ -529,19 +529,19 @@ export default class Tooltip {
529
529
syncedCharts = this . ctx . getSyncedCharts ( )
530
530
}
531
531
532
- let isStickyTooltip =
532
+ const isStickyTooltip =
533
533
w . globals . xyCharts ||
534
534
( w . config . chart . type === 'bar' &&
535
535
! w . globals . isBarHorizontal &&
536
536
this . tooltipUtil . hasBars ( ) &&
537
537
this . tConfig . shared ) ||
538
538
( w . globals . comboCharts && this . tooltipUtil . hasBars ( ) )
539
539
540
- if (
541
- e . type === 'mousemove ' ||
542
- e . type === 'touchmove' ||
543
- e . type === 'mouseup'
544
- ) {
540
+ const isInteractionInProcess = ( e . type === 'mousemove' || e . type === 'touchmove' || e . type === 'mouseup' )
541
+ const isInteractionEnd = ( e . type === 'mouseout ' || e . type === 'touchend' )
542
+ const isChartContextTarget = w . globals . dom . baseEl . contains ( e . relatedTarget )
543
+
544
+ if ( isInteractionInProcess ) {
545
545
// there is no series to hover over
546
546
if (
547
547
w . globals . collapsedSeries . length +
@@ -555,10 +555,9 @@ export default class Tooltip {
555
555
xcrosshairs . classList . add ( 'apexcharts-active' )
556
556
}
557
557
558
- const hasYAxisTooltip = this . yaxisTooltips . filter ( ( b ) => {
559
- return b === true
560
- } )
561
- if ( this . ycrosshairs !== null && hasYAxisTooltip . length ) {
558
+ const hasYAxisTooltip = this . yaxisTooltips . includes ( true )
559
+
560
+ if ( this . ycrosshairs !== null && hasYAxisTooltip ) {
562
561
this . ycrosshairs . classList . add ( 'apexcharts-active' )
563
562
}
564
563
@@ -568,10 +567,10 @@ export default class Tooltip {
568
567
) {
569
568
this . handleStickyTooltip ( e , clientX , clientY , opt )
570
569
} else {
571
- if (
572
- w . config . chart . type === 'heatmap' ||
573
- w . config . chart . type === 'treemap'
574
- ) {
570
+ const isHeatmap = w . config . chart . type === 'heatmap'
571
+ const isTreemap = w . config . chart . type === 'treemap'
572
+
573
+ if ( isHeatmap || isTreemap ) {
575
574
let markerXY = this . intersect . handleHeatTreeTooltip ( {
576
575
e,
577
576
opt,
@@ -582,8 +581,8 @@ export default class Tooltip {
582
581
x = markerXY . x
583
582
y = markerXY . y
584
583
585
- tooltipEl . style . left = x + 'px'
586
- tooltipEl . style . top = y + 'px'
584
+ tooltipEl . style . left = ` ${ x } px`
585
+ tooltipEl . style . top = ` ${ y } px`
587
586
} else {
588
587
if ( this . tooltipUtil . hasBars ( ) ) {
589
588
this . intersect . handleBarTooltip ( {
@@ -612,7 +611,7 @@ export default class Tooltip {
612
611
613
612
w . globals . dom . baseEl . classList . add ( 'apexcharts-tooltip-active' )
614
613
opt . tooltipEl . classList . add ( 'apexcharts-active' )
615
- } else if ( e . type === 'mouseout' || e . type === 'touchend' ) {
614
+ } else if ( ! isChartContextTarget && isInteractionEnd ) {
616
615
this . handleMouseOut ( opt )
617
616
}
618
617
}
0 commit comments