Skip to content

can't disable zoom after it has been enabled #29

@lnavarette

Description

@lnavarette

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions