Skip to content

Commit

Permalink
remove debounce logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme committed Oct 7, 2024
1 parent ef0b6af commit 6965c17
Showing 1 changed file with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React, { useEffect, useRef, useMemo, useCallback } from 'react';
import React, { useEffect, useRef, useCallback } from 'react';
import { EuiResizeObserver, EuiResizeObserverProps, useEuiTheme } from '@elastic/eui';
import { debounce } from 'lodash';

import type { IInterpreterRenderHandlers, RenderMode } from '@kbn/expressions-plugin/common';
import { createVegaVisualization } from '../vega_visualization';
Expand All @@ -28,8 +27,6 @@ interface VegaVisComponentProps {

type VegaVisController = InstanceType<ReturnType<typeof createVegaVisualization>>;

const DEBOUNCE_INTERVAL = 100;

export const VegaVisComponent = ({
visData,
fireEvent,
Expand Down Expand Up @@ -64,22 +61,11 @@ export const VegaVisComponent = ({
}
}, [renderComplete, visData]);

const resizeChart = useMemo(
() =>
debounce((dimensions) => {
visController.current?.resize(dimensions);
}, DEBOUNCE_INTERVAL),
[]
);

const onContainerResize: EuiResizeObserverProps['onResize'] = useCallback(
(dimensions) => {
if (renderCompleted.current) {
resizeChart(dimensions);
}
},
[resizeChart]
);
const onContainerResize: EuiResizeObserverProps['onResize'] = useCallback((dimensions) => {
if (renderCompleted.current) {
visController.current?.resize(dimensions);
}
}, []);

const euiTheme = useEuiTheme();

Expand Down

0 comments on commit 6965c17

Please sign in to comment.