clientIO / joint

A proven SVG-based JavaScript diagramming library powering exceptional UIs
https://jointjs.com
Mozilla Public License 2.0
4.72k stars 853 forks source link

feat(dia.ToolView): add visibility option callback #2745

Closed kumilingus closed 2 months ago

kumilingus commented 3 months ago

Description

Add a callback visibility option to toggle the tools' visibility based on the current state of the cell view.

With this option and the change introduced in https://github.com/clientIO/joint/pull/2743, the double link tool can be easily implemented as follows:

new dia.ToolsView({
    new linkTools.Remove({
       distance: (linkView) => linkView.getConnectionLength() > 100 ? 20 : '50%'   
    }),
    new linkTools.Remove({
       distance: -20,
       visibility: (linkView) => linkView.getConnectionLength() > 100
    })
})