From 8b1011052dc74ed9762cc5d7e11aa13ed38d8c2f Mon Sep 17 00:00:00 2001 From: hustcc Date: Mon, 11 Dec 2023 17:18:09 +0800 Subject: [PATCH] chore: fix ci --- .../api-chart-emit-enable-disable-tooltip.spec.ts | 4 ++-- .../api-chart-emit-item-tooltip-hide-content.spec.ts | 2 +- __tests__/integration/api-chart-emit-item-tooltip.spec.ts | 4 ++-- __tests__/integration/api-chart-tooltip-multi-chart.spec.ts | 4 ++-- .../stateages-interval-highlight-group-background.ts | 2 +- .../plots/tooltip/alphabet-interval-tooltip-render-update.ts | 4 ++-- __tests__/plots/tooltip/flare-treemap-poptip.ts | 2 +- .../plots/tooltip/profit-interval-legend-filter-ordinal.ts | 2 +- __tests__/plots/tooltip/utils.ts | 4 ++-- src/interaction/tooltip.ts | 5 +++-- 10 files changed, 17 insertions(+), 16 deletions(-) diff --git a/__tests__/integration/api-chart-emit-enable-disable-tooltip.spec.ts b/__tests__/integration/api-chart-emit-enable-disable-tooltip.spec.ts index e28301f22d..9234bdb477 100644 --- a/__tests__/integration/api-chart-emit-enable-disable-tooltip.spec.ts +++ b/__tests__/integration/api-chart-emit-enable-disable-tooltip.spec.ts @@ -57,14 +57,14 @@ describe('chart.emit', () => { chart.emit('tooltip:disable'); await sleep(20); - dispatchFirstElementEvent(barCanvas, 'pointerover'); + dispatchFirstElementEvent(barCanvas, 'pointermove'); await expect(barCanvas).toMatchDOMSnapshot(dir, 'step0', { selector: '.g2-tooltip', }); chart.emit('tooltip:enable'); - dispatchFirstElementEvent(barCanvas, 'pointerover'); + dispatchFirstElementEvent(barCanvas, 'pointermove'); await expect(barCanvas).toMatchDOMSnapshot(dir, 'step1', { selector: '.g2-tooltip', }); diff --git a/__tests__/integration/api-chart-emit-item-tooltip-hide-content.spec.ts b/__tests__/integration/api-chart-emit-item-tooltip-hide-content.spec.ts index cfe90c1551..5800092257 100644 --- a/__tests__/integration/api-chart-emit-item-tooltip-hide-content.spec.ts +++ b/__tests__/integration/api-chart-emit-item-tooltip-hide-content.spec.ts @@ -21,7 +21,7 @@ describe('chart.emit', () => { // chart.on("tooltip:hide") should be called when hiding tooltip. const [tooltipHided, resolveHide] = createPromise(); chart.on('tooltip:hide', receiveExpectData(resolveHide, null)); - dispatchFirstElementEvent(canvas, 'pointerout'); + dispatchFirstElementEvent(canvas, 'pointerleave'); await tooltipHided; }); diff --git a/__tests__/integration/api-chart-emit-item-tooltip.spec.ts b/__tests__/integration/api-chart-emit-item-tooltip.spec.ts index edab11a187..9a58d8891f 100644 --- a/__tests__/integration/api-chart-emit-item-tooltip.spec.ts +++ b/__tests__/integration/api-chart-emit-item-tooltip.spec.ts @@ -35,13 +35,13 @@ describe('chart.emit', () => { // chart.on("tooltip:show", callback) should revive selected data. const [tooltipShowed, resolveShow] = createPromise(); chart.on('tooltip:show', receiveExpectData(resolveShow)); - dispatchFirstElementEvent(canvas, 'pointerover'); + dispatchFirstElementEvent(canvas, 'pointermove'); await tooltipShowed; // chart.on("tooltip:hide") should be called when hiding tooltip. const [tooltipHided, resolveHide] = createPromise(); chart.on('tooltip:hide', receiveExpectData(resolveHide, null)); - dispatchFirstElementEvent(canvas, 'pointerout'); + dispatchFirstElementEvent(canvas, 'pointerleave'); await tooltipHided; }); diff --git a/__tests__/integration/api-chart-tooltip-multi-chart.spec.ts b/__tests__/integration/api-chart-tooltip-multi-chart.spec.ts index b07475fe64..d71967eca4 100644 --- a/__tests__/integration/api-chart-tooltip-multi-chart.spec.ts +++ b/__tests__/integration/api-chart-tooltip-multi-chart.spec.ts @@ -15,8 +15,8 @@ describe('chart.interaction.tooltip', () => { }); await Promise.all([finished0, finished1]); - dispatchFirstElementEvent(canvas1, 'pointerover'); - dispatchFirstElementEvent(canvas2, 'pointerover'); + dispatchFirstElementEvent(canvas1, 'pointermove'); + dispatchFirstElementEvent(canvas2, 'pointermove'); expect( Array.from(document.body.getElementsByClassName('g2-tooltip')).length, ).toBe(2); diff --git a/__tests__/plots/interaction/stateages-interval-highlight-group-background.ts b/__tests__/plots/interaction/stateages-interval-highlight-group-background.ts index 9d1b94e339..606c2fe1b3 100644 --- a/__tests__/plots/interaction/stateages-interval-highlight-group-background.ts +++ b/__tests__/plots/interaction/stateages-interval-highlight-group-background.ts @@ -44,7 +44,7 @@ stateAgesIntervalHighlightGroupBackground.steps = ({ canvas }) => { { skip: true, changeState: () => { - e1.background.dispatchEvent(new CustomEvent('pointerover')); + e1.background.dispatchEvent(new CustomEvent('pointermove')); }, }, step(e2, 'pointerover'), diff --git a/__tests__/plots/tooltip/alphabet-interval-tooltip-render-update.ts b/__tests__/plots/tooltip/alphabet-interval-tooltip-render-update.ts index f92f3df452..3a508673d4 100644 --- a/__tests__/plots/tooltip/alphabet-interval-tooltip-render-update.ts +++ b/__tests__/plots/tooltip/alphabet-interval-tooltip-render-update.ts @@ -41,14 +41,14 @@ alphabetIntervalTooltipRenderUpdate.steps = ({ canvas }) => { await sleep(100); const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME); const [e0] = elements; - e0.dispatchEvent(new CustomEvent('pointerover')); + e0.dispatchEvent(new CustomEvent('pointermove')); }, }, { changeState: async () => { const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME); const [e0] = elements; - e0.dispatchEvent(new CustomEvent('pointerover')); + e0.dispatchEvent(new CustomEvent('pointermove')); }, }, ]; diff --git a/__tests__/plots/tooltip/flare-treemap-poptip.ts b/__tests__/plots/tooltip/flare-treemap-poptip.ts index 7dce6d5b8f..c5ce5487cd 100644 --- a/__tests__/plots/tooltip/flare-treemap-poptip.ts +++ b/__tests__/plots/tooltip/flare-treemap-poptip.ts @@ -69,7 +69,7 @@ flareTreemapPoptip.steps = ({ canvas }) => { }, { changeState: async () => { - rectangle?.dispatchEvent(new CustomEvent('pointerout')); + rectangle?.dispatchEvent(new CustomEvent('pointerleave')); }, skip: true, }, diff --git a/__tests__/plots/tooltip/profit-interval-legend-filter-ordinal.ts b/__tests__/plots/tooltip/profit-interval-legend-filter-ordinal.ts index c413c6c6c1..ddc35debdf 100644 --- a/__tests__/plots/tooltip/profit-interval-legend-filter-ordinal.ts +++ b/__tests__/plots/tooltip/profit-interval-legend-filter-ordinal.ts @@ -37,7 +37,7 @@ profitIntervalLegendFilterOrdinal.steps = ({ canvas }) => { changeState: async () => { const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME); const [e0] = elements; - e0.dispatchEvent(new CustomEvent('pointerover')); + e0.dispatchEvent(new CustomEvent('pointermove')); }, }, ]; diff --git a/__tests__/plots/tooltip/utils.ts b/__tests__/plots/tooltip/utils.ts index df3d05899d..f95245de50 100644 --- a/__tests__/plots/tooltip/utils.ts +++ b/__tests__/plots/tooltip/utils.ts @@ -25,7 +25,7 @@ export function tooltipSteps(...index) { const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME); const steps = index.map((i) => ({ changeState: async () => { - elements[i].dispatchEvent(new CustomEvent('pointerover')); + elements[i].dispatchEvent(new CustomEvent('pointermove')); }, })); return steps; @@ -40,7 +40,7 @@ export function tooltipStepsByMarkType(markType, ...index) { ); const steps = index.map((i) => ({ changeState: async () => { - elements[i].dispatchEvent(new CustomEvent('pointerover')); + elements[i].dispatchEvent(new CustomEvent('pointermove')); }, })); return steps; diff --git a/src/interaction/tooltip.ts b/src/interaction/tooltip.ts index 6ceec7b2f0..17c024e12a 100644 --- a/src/interaction/tooltip.ts +++ b/src/interaction/tooltip.ts @@ -436,7 +436,7 @@ export function seriesTooltip( groupName, emitter, wait = 50, - leading = false, + leading = true, trailing = false, startX = 0, startY = 0, @@ -857,7 +857,7 @@ export function tooltip( const addEventListeners = () => { if (!disableNative) { - console.log(111, 'addEventListeners'); + // root.addEventListener('pointerover', pointerover); root.addEventListener('pointermove', pointerover); // Only emit pointerleave event when the pointer is not in the root area. // !! !DO NOT USE pointerout event, it will emit when the pointer is in the child area. @@ -867,6 +867,7 @@ export function tooltip( const removeEventListeners = () => { if (!disableNative) { + // root.removeEventListener('pointerover', pointerover); root.removeEventListener('pointermove', pointerover); root.removeEventListener('pointerleave', pointerleave); }