clientIO / joint

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

feat(elementTools.Control): add UI event to setPosition() and resetPosition() signature #2742

Closed kumilingus closed 3 months ago

kumilingus commented 3 months ago

Description

The current signature:

abstract class Control extends dia.ToolView {
    protected getPosition(view: dia.ElementView): dia.Point;
    protected setPosition(view: dia.ElementView, coordinates: g.Point): void;
    protected resetPosition(view: dia.ElementView): void;
}

Is changed to:

abstract class Control extends dia.ToolView {
    protected getPosition(view: dia.ElementView): dia.Point;
    protected setPosition(view: dia.ElementView, coordinates: g.Point, evt: dia.Event): void;
    protected resetPosition(view: dia.ElementView, evt: dia.Event): void;
}

This allows anyone to modify the behavior of the control tool based on a UI event. e.g. disable the resize tool from snapping to the grid when the user holds down the Shift key.