lockCamera still almost working
This commit is contained in:
parent
11c88ec0de
commit
1190848222
|
|
@ -137,11 +137,17 @@ export const copyLinkToCurrentView = async (editor: Editor) => {
|
||||||
zoom: camera.z,
|
zoom: camera.z,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Set camera parameters
|
// Set camera parameters first
|
||||||
url.searchParams.set("x", camera.x.toString())
|
url.searchParams.set("x", camera.x.toString())
|
||||||
url.searchParams.set("y", camera.y.toString())
|
url.searchParams.set("y", camera.y.toString())
|
||||||
url.searchParams.set("zoom", camera.z.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()
|
const finalUrl = url.toString()
|
||||||
console.log("Final URL to copy:", finalUrl)
|
console.log("Final URL to copy:", finalUrl)
|
||||||
|
|
||||||
|
|
@ -188,12 +194,15 @@ export const lockCameraToFrame = async (editor: Editor) => {
|
||||||
1, // Cap at 1x zoom
|
1, // Cap at 1x zoom
|
||||||
)
|
)
|
||||||
|
|
||||||
url.searchParams.set("frameId", selectedShape.id)
|
// Set camera parameters first
|
||||||
url.searchParams.set("isLocked", "true")
|
|
||||||
url.searchParams.set("x", bounds.x.toString())
|
url.searchParams.set("x", bounds.x.toString())
|
||||||
url.searchParams.set("y", bounds.y.toString())
|
url.searchParams.set("y", bounds.y.toString())
|
||||||
url.searchParams.set("zoom", targetZoom.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()
|
const finalUrl = url.toString()
|
||||||
|
|
||||||
if (navigator.clipboard && window.isSecureContext) {
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,15 @@ import { Editor, TLShapeId } from "tldraw"
|
||||||
|
|
||||||
export const handleInitialPageLoad = (editor: Editor) => {
|
export const handleInitialPageLoad = (editor: Editor) => {
|
||||||
const url = new URL(window.location.href)
|
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 x = url.searchParams.get("x")
|
||||||
const y = url.searchParams.get("y")
|
const y = url.searchParams.get("y")
|
||||||
const zoom = url.searchParams.get("zoom")
|
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"
|
const isLocked = url.searchParams.get("isLocked") === "true"
|
||||||
|
|
||||||
// Wait for next tick to ensure editor is ready
|
// Wait for next tick to ensure editor is ready
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue