Download manual.js from StoneCandy/StoneCandy-Translator: direct link, hf CLI and curl.
- Browser
- Download file 16.8 kB
-
https://huggingface.co/spaces/StoneCandy/StoneCandy-Translator/resolve/main/manual.js
- Command line
-
hf download hf://spaces/StoneCandy/StoneCandy-Translator/manual.js
-
curl -L -o manual.js https://huggingface.co/spaces/StoneCandy/StoneCandy-Translator/resolve/main/manual.js
16.8 kB
| /* ๋ชฉ์ฐจ ์๋ ์์ฑ + ๋ณธ๋ฌธ/๋ชฉ์ฐจ ์คํฌ๋กค ์ฐ๋ + ๊ธฐ๋ฅ ์๊ฐ ๋๋ค ํ์ */ | |
| (function () { | |
| "use strict"; | |
| var RESYNC_MS = 3000; // ๋ชฉ์ฐจ๋ฅผ ๋ง์ง๊ณ ์ด ์๊ฐ ์ง๋๋ฉด ๋ณธ๋ฌธ ์์น๋ก ๋ณต๊ท (๋ง์ฐ์ค๊ฐ ๋ชฉ์ฐจ ์๋ฉด ์นด์ดํธ ์ ํจ) | |
| var SPY_OFFSET = 100; // ํ๋ฉด ์์์ ์ด ๋์ด ์์ ๋ค์ด์จ ์ ๋ชฉ์ "์ง๊ธ ์ฝ๋ ๊ณณ"์ผ๋ก ๋ด | |
| var JUMP_MARGIN = 24; // ๋ชฉ์ฐจ ํด๋ฆญ ์ ์ ๋ชฉ์ ํ๋ฉด ์์์ ์ด๋งํผ ๋์ ๋ฉ์ถค | |
| var manual = document.getElementById("manual"); | |
| var tocBox = document.getElementById("toc-scroll"); | |
| var tocList = document.getElementById("toc-list"); | |
| var heads = Array.prototype.slice.call(manual.querySelectorAll("h2[id], h3[id]")); | |
| var linkById = {}; | |
| // ---------- ๋ชฉ์ฐจ ์์ฑ ---------- | |
| function roman(n) { | |
| var r = "", v = [10, 9, 5, 4, 1], c = ["X", "IX", "V", "IV", "I"]; | |
| for (var i = 0; i < v.length; i++) while (n >= v[i]) { r += c[i]; n -= v[i]; } | |
| return r; | |
| } | |
| var subCount = 0; | |
| heads.forEach(function (h) { | |
| var li = document.createElement("li"); | |
| var a = document.createElement("a"); | |
| a.href = "#" + h.id; | |
| if (h.dataset.num) { // ๋์ ๋ชฉ์ ์ฅ ๋ฒํธ๋ฅผ ์์ ๋ถ์ | |
| var num = document.createElement("span"); | |
| num.className = "toc-num"; | |
| num.textContent = h.dataset.num; | |
| a.appendChild(num); | |
| } | |
| if (h.tagName === "H2") subCount = 0; | |
| if (h.tagName === "H3" && h.closest(".chapter")) { // ์์ ๋ชฉ์ ๋ณธ๋ฌธ์ฒ๋ผ ์ฅ๋ง๋ค I. II. ... | |
| var sub = document.createElement("span"); | |
| sub.className = "toc-sub"; | |
| sub.textContent = roman(++subCount) + "."; | |
| a.appendChild(sub); | |
| } | |
| var label = document.createElement("span"); | |
| label.textContent = h.getAttribute("data-toc") || h.textContent; | |
| a.appendChild(label); | |
| a.className = "lv-" + h.tagName.toLowerCase(); | |
| if (h.closest(".draft")) a.classList.add("is-draft"); | |
| a.addEventListener("click", function (e) { | |
| e.preventDefault(); | |
| goTo(h.id, false); | |
| }); | |
| li.appendChild(a); | |
| tocList.appendChild(li); | |
| linkById[h.id] = a; | |
| }); | |
| // ---------- ๊ฐ์กฐ ๋ฐฐ๊ฒฝ(๋ค๋ชจ ๋ ์ด์ด) ---------- | |
| var marker = document.createElement("div"); | |
| marker.className = "toc-marker"; | |
| tocBox.insertBefore(marker, tocList); | |
| function moveMarker(id) { | |
| var a = linkById[id]; | |
| if (!a) return; | |
| var top = tocList.offsetTop + a.offsetTop; // a์ ๊ธฐ์ค์ ul(position: relative) | |
| marker.style.transform = "translateY(" + top + "px)"; | |
| marker.style.height = a.offsetHeight + "px"; | |
| } | |
| window.addEventListener("resize", function () { if (activeId) moveMarker(activeId); }); | |
| // ---------- ์ํ ---------- | |
| var activeId = null; | |
| var lockedId = null; // ๋ชฉ์ฐจ ํด๋ฆญ์ผ๋ก ์ด๋ํ ์น์ . ์ฌ์ฉ์๊ฐ ๋ณธ๋ฌธ์ ์ง์ ์์ง์ด๊ธฐ ์ ๊น์ง ๊ณ ์ | |
| var detached = false; // ์ฌ์ฉ์๊ฐ ๋ชฉ์ฐจ๋ฅผ ์ง์ ์คํฌ๋กคํด์ ๋ณธ๋ฌธ๊ณผ ์ด๊ธ๋ ์ํ | |
| var hovering = false; // ๋ง์ฐ์ค๊ฐ ๋ชฉ์ฐจ ์์ ์์ | |
| var timer = null; | |
| function setActive(id, syncToc) { | |
| if (id === activeId) return; | |
| if (activeId && linkById[activeId]) linkById[activeId].classList.remove("active"); | |
| activeId = id; | |
| if (linkById[id]) linkById[id].classList.add("active"); | |
| moveMarker(id); | |
| if (syncToc && !detached) scrollTocTo(id, true); | |
| } | |
| // ๋ชฉ์ฐจ ์นธ ์์์ ํด๋น ํญ๋ชฉ์ ๊ฐ์ด๋ฐ๋ก (๋ชฉ์ฐจ ์นธ๋ง ์์ง์, ๋ณธ๋ฌธ์ ์ ์์ง์) | |
| function scrollTocTo(id, smooth) { | |
| var a = linkById[id]; | |
| if (!a) return; | |
| var boxTop = tocBox.getBoundingClientRect().top; | |
| var aTop = a.getBoundingClientRect().top; | |
| var target = tocBox.scrollTop + (aTop - boxTop) - (tocBox.clientHeight - a.offsetHeight) / 2; | |
| tocBox.scrollTo({ top: Math.max(0, target), behavior: smooth ? "smooth" : "auto" }); | |
| } | |
| // ์ง๊ธ ๋ณธ๋ฌธ์์ ์ฝ๊ณ ์๋ ์ ๋ชฉ | |
| function currentHead() { | |
| var doc = document.documentElement; | |
| if (window.innerHeight + window.scrollY >= doc.scrollHeight - 2) return heads[heads.length - 1]; | |
| var cur = heads[0]; | |
| for (var i = 0; i < heads.length; i++) { | |
| // ๋์ ๋ชฉ์ ์ฅ ๋งจ ์(์ฅ ๋ฒํธ ํฌํจ)๋ฅผ ๊ธฐ์ค์ผ๋ก ํ๋จ | |
| var ref = (heads[i].tagName === "H2" && heads[i].closest(".chapter")) || heads[i]; | |
| if (ref.getBoundingClientRect().top - SPY_OFFSET <= 0) cur = heads[i]; | |
| else break; | |
| } | |
| return cur; | |
| } | |
| // ---------- ๋ณธ๋ฌธ ์คํฌ๋กค โ ๋ชฉ์ฐจ ๋ฐ๋ผ์ด ---------- | |
| var ticking = false; | |
| window.addEventListener("scroll", function () { | |
| if (ticking) return; | |
| ticking = true; | |
| requestAnimationFrame(function () { | |
| ticking = false; | |
| if (lockedId) return; | |
| var h = currentHead(); | |
| if (h) setActive(h.id, true); | |
| }); | |
| }, { passive: true }); | |
| // ์ฌ์ฉ์๊ฐ ๋ณธ๋ฌธ์ ์ง์ ์์ง์ด๋ฉด ํด๋ฆญ ๊ณ ์ ํด์ | |
| function releaseLock(e) { | |
| if (e && e.target && tocBox.contains(e.target)) return; | |
| if (!lockedId) return; | |
| lockedId = null; | |
| } | |
| window.addEventListener("wheel", releaseLock, { passive: true }); | |
| window.addEventListener("touchstart", releaseLock, { passive: true }); | |
| window.addEventListener("mousedown", releaseLock); | |
| window.addEventListener("keydown", releaseLock); | |
| // ---------- ๋ชฉ์ฐจ ์ง์ ์คํฌ๋กค โ ๋ณธ๋ฌธ์ ๊ทธ๋๋ก, 3์ด ๋ค ๋ณต๊ท ---------- | |
| // wheel/touch/์คํฌ๋กค๋ฐ ๋๋๊ทธ๋ ์ฌ์ฉ์๋ง ์ผ์ผํค๋ฏ๋ก, ํ๋ก๊ทธ๋จ์ด ๋ชฉ์ฐจ๋ฅผ ์์ง์ธ ๊ฒ๊ณผ ์์ด์ง ์์ | |
| function userTouchedToc() { | |
| detached = true; | |
| restartTimer(); | |
| } | |
| function restartTimer() { | |
| clearTimeout(timer); | |
| timer = null; | |
| if (detached && !hovering) timer = setTimeout(reattach, RESYNC_MS); | |
| } | |
| function reattach() { | |
| timer = null; | |
| detached = false; | |
| if (activeId) scrollTocTo(activeId, true); | |
| } | |
| tocBox.addEventListener("wheel", userTouchedToc, { passive: true }); | |
| tocBox.addEventListener("touchmove", userTouchedToc, { passive: true }); | |
| tocBox.addEventListener("mousedown", function (e) { | |
| if (e.target === tocBox) userTouchedToc(); // ์คํฌ๋กค๋ฐ ์ก๊ณ ๋๋๊ทธ | |
| }); | |
| tocBox.addEventListener("mouseenter", function () { | |
| hovering = true; | |
| clearTimeout(timer); // ๋ง์ฐ์ค๊ฐ ๋ชฉ์ฐจ ์์ ์๋ ๋์์ ์นด์ดํธ ์ ํจ | |
| timer = null; | |
| }); | |
| tocBox.addEventListener("mouseleave", function () { | |
| hovering = false; | |
| restartTimer(); // ๋ฒ์ด๋ ์๊ฐ๋ถํฐ 3์ด | |
| }); | |
| // ---------- ๋ชฉ์ฐจ ํด๋ฆญ / ๊ธฐ๋ฅ ์๊ฐ ๋ฒํผ โ ๋ณธ๋ฌธ ์ด๋ ---------- | |
| function goTo(id, syncToc) { | |
| var h = document.getElementById(id); | |
| if (!h) return; | |
| // ์ ๋ชฉ์ด ์๋ ์์(์: ์ฌ์ฉํ ํญ๋ชฉ)๋ก ๊ฐ ๋๋ ๊ทธ ์์ ๊ฐ์ฅ ๊ฐ๊น์ด ์ ๋ชฉ์ ๋ชฉ์ฐจ์ ํ์ | |
| var tocId = id; | |
| if (!linkById[id]) { | |
| tocId = heads[0].id; | |
| heads.forEach(function (hd) { | |
| if (hd.compareDocumentPosition(h) & Node.DOCUMENT_POSITION_FOLLOWING) tocId = hd.id; | |
| }); | |
| } | |
| lockedId = tocId; | |
| detached = false; | |
| clearTimeout(timer); | |
| timer = null; | |
| setActive(tocId, false); | |
| if (syncToc) scrollTocTo(tocId, true); | |
| // ๋์ ๋ชฉ์ผ๋ก ๊ฐ ๋๋ ์ฅ ๋ฒํธ๊น์ง ๋ณด์ด๋๋ก ์ฅ ๋งจ ์๋ก | |
| var anchor = (h.tagName === "H2" && h.closest(".chapter")) || h; | |
| var y = anchor.getBoundingClientRect().top + window.scrollY - (anchor === h ? JUMP_MARGIN : 0); | |
| window.scrollTo({ top: Math.max(0, y), behavior: "smooth" }); | |
| try { history.replaceState(null, "", "#" + id); } catch (err) { /* file:// ์์ ๋งํ๋ฉด ๋ฌด์ */ } | |
| } | |
| window.manualGoTo = goTo; | |
| // ---------- ์ฒ์ ์ด ๋ ---------- | |
| var first = location.hash && document.getElementById(location.hash.slice(1)); | |
| var startHead = first && heads.indexOf(first) >= 0 ? first : currentHead(); | |
| if (startHead) { | |
| setActive(startHead.id, false); | |
| scrollTocTo(startHead.id, false); | |
| } | |
| // ์ฒ์ ์์น๋ ์ ๋๋ฉ์ด์ ์์ด ์ก๊ณ , ๊ทธ ๋ค์๋ถํฐ ๋ถ๋๋ฝ๊ฒ | |
| requestAnimationFrame(function () { | |
| requestAnimationFrame(function () { marker.classList.add("animate"); }); | |
| }); | |
| // ---------- ๊ธฐ๋ฅ ์๊ฐ(๊ด๊ณ ) ์น์ ---------- | |
| var promo = document.getElementById("promo"); | |
| var items = window.MANUAL_PROMOS || []; | |
| var lastIndex = -1; | |
| function pickIndex() { | |
| if (items.length <= 1) return 0; | |
| var i; | |
| do { i = Math.floor(Math.random() * items.length); } while (i === lastIndex); | |
| return i; | |
| } | |
| function renderPromo() { | |
| if (!items.length) { promo.hidden = true; return; } | |
| lastIndex = pickIndex(); | |
| var it = items[lastIndex]; | |
| promo.innerHTML = ""; | |
| var head = document.createElement("div"); | |
| head.className = "side-title"; | |
| head.textContent = "๊ธฐ๋ฅ ์๊ฐ"; | |
| promo.appendChild(head); | |
| var media = document.createElement("div"); | |
| media.className = "promo-media"; | |
| var el; | |
| if (it.type === "video") { | |
| el = document.createElement("video"); | |
| el.src = it.src; | |
| el.autoplay = true; | |
| el.muted = true; | |
| el.loop = true; | |
| el.playsInline = true; | |
| if (it.poster) el.poster = it.poster; | |
| } else { | |
| el = document.createElement("img"); | |
| el.src = it.src; | |
| el.alt = it.title || ""; | |
| } | |
| media.appendChild(el); | |
| if (it.target) media.addEventListener("click", function () { goTo(it.target, true); }); | |
| promo.appendChild(media); | |
| var body = document.createElement("div"); | |
| body.className = "promo-body"; | |
| if (it.title) { | |
| var t = document.createElement("p"); | |
| t.className = "promo-title"; | |
| t.textContent = it.title; | |
| body.appendChild(t); | |
| } | |
| if (it.desc) { | |
| var d = document.createElement("p"); | |
| d.className = "promo-desc"; | |
| d.textContent = it.desc; | |
| body.appendChild(d); | |
| } | |
| var actions = document.createElement("div"); | |
| actions.className = "promo-actions"; | |
| if (it.target) { | |
| var go = document.createElement("button"); | |
| go.className = "primary"; | |
| go.textContent = "๋งค๋ด์ผ์์ ๋ณด๊ธฐ"; | |
| go.addEventListener("click", function () { goTo(it.target, true); }); | |
| actions.appendChild(go); | |
| } | |
| if (items.length > 1) { | |
| var next = document.createElement("button"); | |
| next.textContent = "๋ค๋ฅธ ๊ธฐ๋ฅ"; | |
| next.addEventListener("click", renderPromo); | |
| actions.appendChild(next); | |
| } | |
| body.appendChild(actions); | |
| promo.appendChild(body); | |
| } | |
| // ๊ธฐ๋ฅ ์๊ฐ๋ ๊บผ ๋๊ณ , ๋ชฉ์ฐจ ์๋๋ฅผ ์์ ๋ง๊ฐ ์ค๋ก ์ด๋ค. ๋ค์ ์ฐ๋ ค๋ฉด ์๋ ๋์ renderPromo()๋ฅผ ๋ถ๋ฅธ๋ค. | |
| function renderSideFoot() { | |
| promo.hidden = false; | |
| promo.innerHTML = ""; | |
| promo.className = "promo side-foot"; | |
| promo.setAttribute("aria-label", "StoneCandy Translator"); | |
| var bar = document.createElement("div"); | |
| bar.className = "side-foot-bar"; | |
| var name = document.createElement("span"); | |
| name.className = "side-foot-name"; | |
| name.textContent = "StoneCandy Translator"; | |
| var ver = document.createElement("span"); | |
| ver.className = "side-foot-ver"; | |
| ver.textContent = "Ver. 0.99.2"; | |
| bar.appendChild(name); | |
| bar.appendChild(ver); | |
| promo.appendChild(bar); // ๋ธ๋๋ ์ค: ๋ชฉ์ฐจ์ ๋ผ์ด์ ์ค ์นด๋ ์ฌ์ด ๊ตฌ๋ถ์ ์ญํ | |
| // ๊ด๊ณ ์์ ์๋ฆฌ๋ ๋ผ์ด์ ์ค ์นด๋(index.html์ .side-license)๋ก ๋ฐ๋์๋ค. ์์ ํ์ผ์ doc/video์ ๊ทธ๋๋ก ๋๋ค. | |
| } | |
| // [์ค๋น์ค] ์นธ (์์ ์๋ฆฌ ํ์). ์ง๊ธ์ ์ ์. | |
| function renderPromoPlaceholder() { | |
| promo.hidden = false; | |
| promo.innerHTML = ""; | |
| var head = document.createElement("div"); | |
| head.className = "side-title"; | |
| head.textContent = "๊ธฐ๋ฅ ์๊ฐ"; | |
| promo.appendChild(head); | |
| var body = document.createElement("div"); | |
| body.className = "promo-body promo-placeholder"; | |
| var d = document.createElement("p"); | |
| d.className = "promo-desc"; | |
| d.textContent = "[์ค๋น์ค]"; | |
| body.appendChild(d); | |
| promo.appendChild(body); | |
| } | |
| // ๋ธ๋๋ ์ค(StoneCandy Translator ยท Ver.)์ ๋ผ์ด์ ์ค ์นด๋ ๋จธ๋ฆฌ ์ค(index.html .lic-head)๋ก ๋์ ํ๋ค. ๋๋๋ฆฌ๋ ค๋ฉด ์๋ ๋์ renderSideFoot()๋ฅผ ๋ถ๋ฅธ๋ค. | |
| promo.hidden = true; | |
| // ---------- ๊ทธ๋ฆผ ํด๋ฆญ ํ๋ (๋ค์ ํด๋ฆญํ๊ฑฐ๋ Esc๋ก ๋ซ๊ธฐ) ---------- | |
| var box = document.createElement("div"); | |
| box.className = "lightbox"; | |
| box.hidden = true; | |
| var big = document.createElement("img"); | |
| big.alt = ""; | |
| box.appendChild(big); | |
| document.body.appendChild(box); | |
| function openBox(src, alt) { | |
| big.src = src; | |
| big.alt = alt || ""; | |
| box.hidden = false; | |
| void box.offsetWidth; // ํ๋ฉด์ ๋ถ์ธ ๋ค ๋ฐ๋ก ํ์ด๋์ธ ์์ | |
| box.classList.add("open"); | |
| document.documentElement.classList.add("no-scroll"); | |
| } | |
| function closeBox() { | |
| box.classList.remove("open"); | |
| document.documentElement.classList.remove("no-scroll"); | |
| setTimeout(function () { if (!box.classList.contains("open")) box.hidden = true; }, 200); | |
| } | |
| manual.addEventListener("click", function (e) { | |
| var img = e.target.closest(".shot img, .compare img"); | |
| if (img) openBox(img.currentSrc || img.src, img.alt); | |
| var hero = e.target.closest("img.hero-art[data-full]"); // ์ฒซ ํ๋ฉด ๊ทธ๋ฆผ: ํฐ ๊ทธ๋ฆผ์ผ๋ก ํ๋ | |
| if (hero) openBox(hero.getAttribute("data-full"), hero.alt); | |
| var link = e.target.closest("a.popup-img"); // '์์' ๊ฐ์ ๊ธ์ ๋งํฌ๋ ๊ฐ์ ํ๋ ์ฐฝ์ผ๋ก | |
| if (link) { | |
| e.preventDefault(); | |
| openBox(link.href, link.getAttribute("data-alt") || link.textContent); | |
| } | |
| }); | |
| box.addEventListener("click", closeBox); | |
| document.addEventListener("keydown", function (e) { | |
| if (e.key === "Escape" && !box.hidden) closeBox(); | |
| }); | |
| })(); | |
| // ---------- Model Test: ๋ฐ๋ชจ(Gradio)๋ฅผ ํ์ iframe์ผ๋ก ---------- | |
| // ๋ฒํผ์ data-local / data-web ์ฃผ์๋ฅผ iframe์ ๋์ด๋ค. Space์ ์ฌ๋ฆฌ๋ฉด index.html์ data-web๋ง ์ฑ์ด๋ค. | |
| (function () { | |
| var frameBox = null, frame, titleEl; | |
| function build() { | |
| frameBox = document.createElement("div"); | |
| frameBox.className = "frame-pop"; | |
| frameBox.hidden = true; | |
| frameBox.innerHTML = | |
| '<div class="frame-pop-panel" role="dialog">' + | |
| '<div class="frame-pop-bar"><b></b>' + | |
| '<a class="frame-pop-new" target="_blank" rel="noopener">์ ์ฐฝ์ผ๋ก</a>' + | |
| '<button type="button" class="frame-pop-close" aria-label="๋ซ๊ธฐ">×</button></div>' + | |
| '<iframe title="Model Test" allow="clipboard-read; clipboard-write"></iframe>' + | |
| '</div>'; | |
| document.body.appendChild(frameBox); | |
| frame = frameBox.querySelector("iframe"); | |
| titleEl = frameBox.querySelector(".frame-pop-bar b"); | |
| frameBox.addEventListener("click", function (e) { | |
| if (e.target === frameBox || e.target.closest(".frame-pop-close")) close(); | |
| }); | |
| } | |
| function open(url, title) { | |
| if (!frameBox) build(); | |
| titleEl.textContent = title || ""; | |
| frameBox.querySelector(".frame-pop-new").href = url; | |
| if (frame.getAttribute("src") !== url) frame.src = url; // ํ ๋ฒ ๋์ด ๋ฐ๋ชจ๋ ๋ซ์๋ ๊ทธ๋๋ก ๋๋ค | |
| frameBox.hidden = false; | |
| document.documentElement.classList.add("no-scroll"); | |
| } | |
| function close() { | |
| frameBox.hidden = true; | |
| document.documentElement.classList.remove("no-scroll"); | |
| } | |
| // ๋งค๋ด์ผ์ ๋ก์ปฌ(localhostยท127.0.0.1ยทํ์ผ)์์ ์ด์์ผ๋ฉด ๋ก์ปฌ ๋ฐ๋ชจ, ์น(Hugging Face)์ด๋ฉด Space ์ฃผ์ | |
| function isLocalPage() { | |
| var h = location.hostname; | |
| return location.protocol === "file:" || h === "localhost" || h === "127.0.0.1" || h === "[::1]" || h === ""; | |
| } | |
| function demoUrl(a) { | |
| var local = a.getAttribute("data-local"), web = a.getAttribute("data-web"); | |
| return (isLocalPage() ? local : web) || a.href; | |
| } | |
| document.querySelectorAll("a.popup-frame").forEach(function (a) { a.href = demoUrl(a); }); // Ctrl+ํด๋ฆญ ์ ํญ๋ ๊ฐ์ ์ฃผ์๋ก | |
| document.addEventListener("click", function (e) { | |
| var a = e.target.closest("a.popup-frame"); | |
| if (!a || e.ctrlKey || e.metaKey || e.shiftKey || e.button !== 0) return; // Ctrl+ํด๋ฆญ์ ๊ทธ๋ฅ ์ ํญ | |
| e.preventDefault(); | |
| open(demoUrl(a), a.getAttribute("data-title")); | |
| }); | |
| document.addEventListener("keydown", function (e) { | |
| if (e.key === "Escape" && frameBox && !frameBox.hidden) close(); | |
| }); | |
| })(); | |
| // ๋ชฉ์ฐจ ยท Models used ์ 2ร2 ํ์ผ: ์นธ 5px ยท ํ 1px์ ์ค์ ํ๋ฉด ํฝ์ ์ ์๋ก ๋ง์ถ๋ค. | |
| // ํ๋ฉด ๋ฐฐ์จ(125 % ๋ฑ)์ด๋ ํ๋ยท์ถ์ ๋ ์นธ ํฌ๊ธฐ๊ฐ ์ ์๊ฐ ์๋๋ฉด ์์๋ ํ์ด 1px/2px๋ก ๋ฌ๋ผ ๋ณด์ด๊ธฐ ๋๋ฌธ. | |
| (function () { | |
| function snapTiles() { | |
| var d = window.devicePixelRatio || 1; | |
| var s = document.documentElement.style; | |
| s.setProperty('--tile', Math.max(3, Math.round(5 * d)) / d + 'px'); | |
| s.setProperty('--tile-gap', Math.max(1, Math.round(d)) / d + 'px'); | |
| } | |
| snapTiles(); | |
| window.addEventListener('resize', snapTiles); | |
| })(); | |