lockCamera still almost working
This commit is contained in:
parent
3c8f4d7fd1
commit
3a5148c68b
|
|
@ -137,11 +137,17 @@ export const copyLinkToCurrentView = async (editor: Editor) => {
|
|||
zoom: camera.z,
|
||||
})
|
||||
|
||||
// Set camera parameters
|
||||
// Set camera parameters first
|
||||
url.searchParams.set("x", camera.x.toString())
|
||||
url.searchParams.set("y", camera.y.toString())
|
||||
url.searchParams.set("zoom", camera.z.toString())
|
||||
|
||||
// Add shape ID last if needed
|
||||
const selectedIds = editor.getSelectedShapeIds()
|
||||
if (selectedIds.length > 0) {
|
||||
url.searchParams.set("shapeId", selectedIds[0].toString())
|
||||
}
|
||||
|
||||
const finalUrl = url.toString()
|
||||
console.log("Final URL to copy:", finalUrl)
|
||||
|
||||
|
|
@ -188,12 +194,15 @@ export const lockCameraToFrame = async (editor: Editor) => {
|
|||
1, // Cap at 1x zoom
|
||||
)
|
||||
|
||||
url.searchParams.set("frameId", selectedShape.id)
|
||||
url.searchParams.set("isLocked", "true")
|
||||
// Set camera parameters first
|
||||
url.searchParams.set("x", bounds.x.toString())
|
||||
url.searchParams.set("y", bounds.y.toString())
|
||||
url.searchParams.set("zoom", targetZoom.toString())
|
||||
|
||||
// Add frame-specific parameters last
|
||||
url.searchParams.set("isLocked", "true")
|
||||
url.searchParams.set("frameId", selectedShape.id)
|
||||
|
||||
const finalUrl = url.toString()
|
||||
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,15 @@ import { Editor, TLShapeId } from "tldraw"
|
|||
|
||||
export const handleInitialPageLoad = (editor: Editor) => {
|
||||
const url = new URL(window.location.href)
|
||||
const frameId = url.searchParams.get("frameId")
|
||||
const shapeId = url.searchParams.get("shapeId")
|
||||
|
||||
// Get camera parameters first
|
||||
const x = url.searchParams.get("x")
|
||||
const y = url.searchParams.get("y")
|
||||
const zoom = url.searchParams.get("zoom")
|
||||
|
||||
// Get shape/frame parameters last
|
||||
const frameId = url.searchParams.get("frameId")
|
||||
const shapeId = url.searchParams.get("shapeId")
|
||||
const isLocked = url.searchParams.get("isLocked") === "true"
|
||||
|
||||
// Wait for next tick to ensure editor is ready
|
||||
|
|
|
|||
Loading…
Reference in New Issue