From 7f32405d0f182e9b347682e49a2aff6523e1272b 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 bda4b47abf..f78abaad03 100644 --- a/__tests__/integration/api-chart-emit-enable-disable-tooltip.spec.ts +++ b/__tests__/integration/api-chart-emit-enable-disable-tooltip.spec.ts @@ -57,7 +57,7 @@ describe('chart.emit', () => { chart.emit('tooltip:disable'); await sleep(20); - dispatchFirstElementEvent(barCanvas, 'pointerover'); + dispatchFirstElementEvent(barCanvas, 'pointermove'); await expect(barCanvas).toMatchDOMSnapshot(dir, 'step0', { fileFormat: 'html', selector: '.g2-tooltip', @@ -65,7 +65,7 @@ describe('chart.emit', () => { chart.emit('tooltip:enable'); - dispatchFirstElementEvent(barCanvas, 'pointerover'); + dispatchFirstElementEvent(barCanvas, 'pointermove'); await expect(barCanvas).toMatchDOMSnapshot(dir, 'step1', { fileFormat: 'html', 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 601933db31..04d5deea81 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 21e2d4196c..2ccef4f334 100644 --- a/__tests__/integration/api-chart-emit-item-tooltip.spec.ts +++ b/__tests__/integration/api-chart-emit-item-tooltip.spec.ts @@ -37,13 +37,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 3c91d1a6eb..7c0d7b651b 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 18c1dcc816..5bc4fcee50 100644 --- a/src/interaction/tooltip.ts +++ b/src/interaction/tooltip.ts @@ -438,7 +438,7 @@ export function seriesTooltip( groupName, emitter, wait = 50, - leading = false, + leading = true, trailing = false, startX = 0, startY = 0, @@ -860,7 +860,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. @@ -870,6 +870,7 @@ export function tooltip( const removeEventListeners = () => { if (!disableNative) { + // root.removeEventListener('pointerover', pointerover); root.removeEventListener('pointermove', pointerover); root.removeEventListener('pointerleave', pointerleave); }