fix zoom & videochat

This commit is contained in:
Jeff Emmett 2025-09-01 09:44:52 +02:00
parent 9baa5968c0
commit 0599cc149c
2 changed files with 13 additions and 13 deletions

View File

@ -64,9 +64,9 @@ export function useCameraControls(editor: Editor | null) {
if (!editor) return if (!editor) return
const camera = editor.getCamera() const camera = editor.getCamera()
const url = new URL(window.location.href) const url = new URL(window.location.href)
url.searchParams.set("x", Math.round(camera.x).toString()) url.searchParams.set("x", camera.x.toFixed(2))
url.searchParams.set("y", Math.round(camera.y).toString()) url.searchParams.set("y", camera.y.toFixed(2))
url.searchParams.set("zoom", Math.round(camera.z).toString()) url.searchParams.set("zoom", camera.z.toFixed(2))
navigator.clipboard.writeText(url.toString()) navigator.clipboard.writeText(url.toString())
}, },

View File

@ -81,9 +81,9 @@ export const zoomToSelection = (editor: Editor) => {
const newCamera = editor.getCamera() const newCamera = editor.getCamera()
const url = new URL(window.location.href) const url = new URL(window.location.href)
url.searchParams.set("shapeId", selectedIds[0].toString()) url.searchParams.set("shapeId", selectedIds[0].toString())
url.searchParams.set("x", Math.round(newCamera.x).toString()) url.searchParams.set("x", newCamera.x.toFixed(2))
url.searchParams.set("y", Math.round(newCamera.y).toString()) url.searchParams.set("y", newCamera.y.toFixed(2))
url.searchParams.set("zoom", Math.round(newCamera.z).toString()) url.searchParams.set("zoom", newCamera.z.toFixed(2))
window.history.replaceState(null, "", url.toString()) window.history.replaceState(null, "", url.toString())
} }
@ -130,10 +130,10 @@ export const copyLinkToCurrentView = async (editor: Editor) => {
const url = new URL(baseUrl) const url = new URL(baseUrl)
const camera = editor.getCamera() const camera = editor.getCamera()
// Round camera values to integers // Preserve two decimal points for camera values
url.searchParams.set("x", Math.round(camera.x).toString()) url.searchParams.set("x", camera.x.toFixed(2))
url.searchParams.set("y", Math.round(camera.y).toString()) url.searchParams.set("y", camera.y.toFixed(2))
url.searchParams.set("zoom", Math.round(camera.z).toString()) url.searchParams.set("zoom", camera.z.toFixed(2))
const selectedIds = editor.getSelectedShapeIds() const selectedIds = editor.getSelectedShapeIds()
if (selectedIds.length > 0) { if (selectedIds.length > 0) {
@ -295,9 +295,9 @@ export const setInitialCameraFromUrl = (editor: Editor) => {
editor.stopCameraAnimation() editor.stopCameraAnimation()
editor.setCamera( editor.setCamera(
{ {
x: Math.round(parseFloat(x)), x: parseFloat(x),
y: Math.round(parseFloat(y)), y: parseFloat(y),
z: Math.round(parseFloat(zoom)) z: parseFloat(zoom)
}, },
{ animation: { duration: 0 } } { animation: { duration: 0 } }
) )