Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: zoomToElement with offset #496

Open
lucasmoeskops opened this issue Jul 15, 2024 · 1 comment
Open

Feature Request: zoomToElement with offset #496

lucasmoeskops opened this issue Jul 15, 2024 · 1 comment

Comments

@lucasmoeskops
Copy link

I'm using this really nice module on a container with a transparent popup on the side which allows to zoom to certain locations. This works really nice with zoomToElement. However, because of the pop-up taking up half of the screen it feels off to have the element in the center of the screen. It would be nice for me if the zoomToElement optionally accepts an xOffset and yOffset so I can zoom to the element with a small offset.

Another possibility for me to solve this problem would be if there was a function that allows me to get the position of an element as a transform state, maybe something like getPositionOfElement(scale) that returns a {xPosition, yPosition, scale}.

These functions already kind of exist in the code I see, but they are not currently exported.

Thanks for considering!

@osmanraifgunes
Copy link

I used following logic to give offset relative to svg and zoom target element ratio :

var scl = Math.round(target.viewportElement.getBoundingClientRect().width / (target.getBoundingClientRect().width * 10));

zoomTo(target, scl);

Increase multiplier of divider (10) to increase offset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants