| 273 | } |
| 274 | |
| 275 | function ensureSnapGuides() { |
| 276 | if (snapGuideV && snapGuideH) return { v: snapGuideV, h: snapGuideH }; |
| 277 | const root = preview; |
| 278 | if (!root) return { v: null, h: null }; |
| 279 | // Guides should move/scale with the preview itself. |
| 280 | snapGuideV = document.createElement("div"); |
| 281 | snapGuideV.className = "snap-guide v"; |
| 282 | snapGuideH = document.createElement("div"); |
| 283 | snapGuideH.className = "snap-guide h"; |
| 284 | root.appendChild(snapGuideV); |
| 285 | root.appendChild(snapGuideH); |
| 286 | return { v: snapGuideV, h: snapGuideH }; |
| 287 | } |
| 288 | |
| 289 | function hideSnapGuides() { |
| 290 | if (snapGuideV) snapGuideV.classList.remove("show"); |