diff --git a/LetterComposer copy.jsx b/LetterComposer copy.jsx index 71c44a5..ec484da 100644 --- a/LetterComposer copy.jsx +++ b/LetterComposer copy.jsx @@ -216,7 +216,7 @@ export default function LetterComposer() { style={{ width: "100vw", height: "100vh", - background: "#f5f6f8", + background: "#d4d4d4", overflow: "hidden", minHeight: "100vh", display: "flex", diff --git a/LetterComposer.jsx b/LetterComposer.jsx index 9f79c41..f955547 100644 --- a/LetterComposer.jsx +++ b/LetterComposer.jsx @@ -3,6 +3,9 @@ import React, { useRef, useState, useEffect } from "react"; const KASZTA_WIDTH = 1618; const KASZTA_HEIGHT = 1080; const SLOTS_COUNT = 20; +const LINE_OFFSET_RIGHT = 340; +const LINE_OFFSET_BOTTOM = 240; +const LETTER_HEIGHT = 96; function getImageWidth(src) { return new Promise((resolve) => { @@ -22,6 +25,7 @@ export default function LetterComposer({ onMoveLineToPage }) { const kasztaRef = useRef(); const wierszownikRef = useRef(); const [kasztaW, setKasztaW] = useState(KASZTA_WIDTH); + const [wierszownikSize, setWierszownikSize] = useState({ w: 0, h: 0 }); // BLOKUJ SCROLL strony useEffect(() => { @@ -160,23 +164,32 @@ export default function LetterComposer({ onMoveLineToPage }) { const scale = kasztaW / KASZTA_WIDTH; const kasztaH = kasztaW * (KASZTA_HEIGHT / KASZTA_WIDTH); const lineW = kasztaW * 0.8; // WIERSZOWNIK 80% kaszty + const lineScale = wierszownikSize.w ? lineW / wierszownikSize.w : scale; + const letterScale = lineScale * 2; + const lineStartX = wierszownikSize.w + ? (wierszownikSize.w - LINE_OFFSET_RIGHT) * lineScale + : 0; + const lineStartY = wierszownikSize.h + ? (wierszownikSize.h - LINE_OFFSET_BOTTOM) * lineScale + : 0; function renderLettersOnLine() { + if (!wierszownikSize.w) return null; let right = 0; let visibleSlots = []; for (let i = slots.length - 1; i >= 0; i--) { const slot = slots[i]; if (!slot) continue; - right += slot.width * scale; + right += slot.width * letterScale; visibleSlots.push(
@@ -206,10 +219,10 @@ export default function LetterComposer({ onMoveLineToPage }) { alt={activeLetter.char} style={{ position: "fixed", - left: ghostPos.x - (activeLetter.width * scale) / 2, - top: ghostPos.y - (96 * scale), - width: activeLetter.width * scale, - height: 96 * scale, + left: ghostPos.x - (activeLetter.width * letterScale) / 2, + top: ghostPos.y - (LETTER_HEIGHT * letterScale), + width: activeLetter.width * letterScale, + height: LETTER_HEIGHT * letterScale, pointerEvents: "none", zIndex: 1000, opacity: 1, @@ -229,7 +242,7 @@ export default function LetterComposer({ onMoveLineToPage }) { minHeight: "100vh", display: "flex", flexDirection: "column", - background: "#f5f6f8", + background: "#d4d4d4", alignItems: "center", justifyContent: "stretch", overflow: "hidden", @@ -324,37 +337,30 @@ export default function LetterComposer({ onMoveLineToPage }) { style={{ position: "relative", width: lineW, - minHeight: 116 * scale, + height: wierszownikSize.h + ? wierszownikSize.h * lineScale + : 116 * scale, margin: "1px auto 0px auto", borderRadius: 8 * scale, - background: "#a6a3a8", touchAction: "none", flexShrink: 0, boxSizing: "border-box" }} > -