-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I am trying to create a button to enable/disable zoom because if you're trying to scroll down the page, the zoom will sometimes get triggered instead depending on where your mouse is.
Here's a component which reproduces this.
function GraphWithLockButton() {
const [locked, setLocked] = useState(true);
return (
<div id={'graph-container'} style={{position: 'relative'}}>
<button onClick={e => setLocked(!locked)}
style={{position: 'absolute', left: 5, top: 5}}>
{locked ? 'locked' : 'unlocked'}
</button>
<Graphviz options={{zoom: !locked, width: 300, height: 300}} dot={`digraph {a -> b}`}/>
</div>
)
}
If the initial state of locked is true,
- Zoom starts off disabled (as expected).
- When you click the button, zoom becomes enabled (as expected)
- When you click the button a second time, state flips to locked, but zoom is still enabled
If the initial state of locked is false,
- Zoom starts off enabled (as expected).
- When you click the button, state flips to locked, but zoom is still enabled
Tested on both 1.0.6 and 1.1.1
Metadata
Metadata
Assignees
Labels
No labels