https://github.com/laszlokorte/svg-viewbox-trans
This is an experiment to transform coordinates from the viewport space (`clientX`, `clientY`) into the local SVG without using `svg.getScreenCTM()`.
https://github.com/laszlokorte/svg-viewbox-trans
Last synced: about 2 months ago
JSON representation
This is an experiment to transform coordinates from the viewport space (`clientX`, `clientY`) into the local SVG without using `svg.getScreenCTM()`.
- Host: GitHub
- URL: https://github.com/laszlokorte/svg-viewbox-trans
- Owner: laszlokorte
- Created: 2023-09-25T14:47:53.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-25T14:50:02.000Z (almost 2 years ago)
- Last Synced: 2025-02-17T09:43:32.821Z (5 months ago)
- Language: Svelte
- Size: 71.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

[Live Demo](https://static.laszlokorte.de/svg-viewbox-trans/)
# Manual SVG ViewBox calculation
This is an experiment to transform coordinates from the viewport space (`clientX`, `clientY`) into the local SVG without using `svg.getScreenCTM()`. The reason for not using `getScreenCTM()` is to be able to do the calculations without updating the SVG DOM element.
Configure the SVG element and ViewBox size and alignment as you like and then click inside the SVG. The red dot shoult be placed correctly at the click position.