KristofferStrube / Blazor.SVGEditor

A basic SVG editor written in Blazor.
https://kristofferstrube.github.io/Blazor.SVGEditor/
MIT License
306 stars 51 forks source link

Feature: Fit viewport to Shapes #21

Closed KristofferStrube closed 6 months ago

KristofferStrube commented 10 months ago

It would be awesome to be able to call some function on the SVGEditor taking a list of shapes that would zoom and translate the viewport of the editor so that the given shapes are centered in the middle of the editor with some padding from the edge of the bounding area.

This could be especially useful in the Blazor.GraphEditor library where nodes' positions are updated continuously.

KristofferStrube commented 10 months ago

It would likewise be able to animate this fit over a period. For this, we can register a Zoom-Translate state and a time when the transition starts, and then when the editor rerenders in the given period after that, calculate its difference to the start time to get a linear transition to the end Zoom-Translate state. This should, of course, be cancelable, and the period should be configurable. Later we can look into making custom transition modes like EaseIn, EaseOut, EaseInOut, etc.