Last active
June 3, 2021 18:52
-
-
Save JakeLaCombe/ed020d0d0bdd8633431834f37de509dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface State { | |
zoomState: 'zoomstart' | 'zoomend' | |
} | |
const VisualizationContext: State = { | |
zoomState: 'zoomend' | |
} | |
const Visualization = (zoomState) => { | |
const svg = d3.render(data) | |
const zoomObject = d3.zoom(); | |
if (zoomState === 'zoomstart') { | |
svg.transition(zoomObject.translate, {x, y}).duration(500).on(dispatchState({zoomState: 'zoomend' })); | |
} | |
} | |
const Panel = () => ( | |
<> | |
<BreadCrumb /> | |
<PanelContent /> | |
<> | |
) useContext(VisualizationContext); | |
const BreadCrumb = () => { | |
return (<button onClick={() => dispatchState({zoomState: 'zoomstart'})}></button>) | |
} | |
const PanelContent = () => { | |
const { zoomState } == useVisualizationContextState(); | |
return (<> | |
<Visualization zoomState={zoomState} /> | |
<>) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment