์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- ์คํฌ๋กค์ ๋๋ฉ์ด์
- JavaScript
- ๋คํฌ๋ชจ๋
- ์น๋์์ธ
- ์น๊ฐ๋ฐ
- ์๋ฐ์คํฌ๋ฆฝํธ
- js์คํฌ๋กค์ด๋ฒคํธ
- ํ๋ก ํธ์๋
- ์ ๊ทผ์ฑ
- ์๋ฐ์คํฌ๋ฆฝํธ์ปดํฌ๋ํธ
- ์คํฌ๋ฆฐ๋ฆฌ๋์ง์
- ui์ปดํฌ๋ํธ
- ์๋ฐ์คํฌ๋ฆฝํธui
- ๋ฐ๋๋ผ์คํฌ๋ฆฝํธ
- ํ ๋ง์๋์ ํ
- ๋ก์ปฌ์คํ ๋ฆฌ์ง
- uiux๋์์ธ
- ์ธํฐ๋ ํฐ๋ธui
- UIUX
- ์นUI
- UX๋์์ธ
- ๋คํฌ๋ชจ๋ํ ๊ธ
- css์ ๋๋ฉ์ด์
- ๋ฐ๋๋ผjs
- ์ฝ๋ฉ์์
- css๋ณ์
- ์น์ ๊ทผ์ฑ
- ๋ฐ์ํ์น
- preferscolorscheme
- ์นui๋์์ธ
- Today
- Total
UI Code Lab
๐ ์คํฌ๋กค ํผ์ผํธ ๊ธฐ๋ฐ ํ๋ก๊ทธ๋ ์ค ๋ฐ ๋ง๋ค๊ธฐ – ๋ฐ๋๋ผ JS๋ก ๊ตฌํํ๋ ์ค์ UI ๋ณธ๋ฌธ
๐ ์คํฌ๋กค ํผ์ผํธ ๊ธฐ๋ฐ ํ๋ก๊ทธ๋ ์ค ๋ฐ ๋ง๋ค๊ธฐ – ๋ฐ๋๋ผ JS๋ก ๊ตฌํํ๋ ์ค์ UI
๐ฏ๊ฟ์์ด๐ 2025. 7. 22. 10:51
์น์ฌ์ดํธ๋ฅผ ์ฝ๋ค ๋ณด๋ฉด ์๋จ์ ์์ ๋ฐ๊ฐ ์ค๋ฅด๋ฅต ์ฐจ์ค๋ฅด๋ ๊ฑธ ๋ณธ ์ ์์ผ์ ๊ฐ์?
์ด๊ฑด ๋ฐ๋ก ์คํฌ๋กค ํผ์ผํธ ๊ธฐ๋ฐ ํ๋ก๊ทธ๋ ์ค ๋ฐ(progress bar)์ ๋๋ค.
์ฌ์ฉ์๊ฐ ํ์ด์ง๋ฅผ ์ผ๋ง๋ ์ฝ์๋์ง ์ง๊ด์ ์ผ๋ก ๋ณด์ฌ์ฃผ๋ UI๋ก,
์ฌ์ฉ์ ๊ฒฝํ(UX)์ ๋์ด๋ ๋ฐ ํจ๊ณผ์ ์ด์์.
์ด๋ฒ ๊ธ์์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์์ด ๋ฐ๋๋ผ JavaScript๋ง์ผ๋ก
์ด ๊ธฐ๋ฅ์ ๊ตฌํํ๋ ๋ฐฉ๋ฒ์ ์๊ฐํฉ๋๋ค.
๐ฏ ๊ตฌํ ๋ชฉํ
- ์ฌ์ฉ์๊ฐ ์คํฌ๋กคํ ๋น์จ์ ๋ฐ๋ผ ์๋จ ๋ฐ์ ๋๋น๊ฐ ์ค์๊ฐ์ผ๋ก ๋ณํจ
- HTML, CSS, JavaScript๋ง ์ฌ์ฉ
- ๋ฐ์ํ ์น์์๋ ์์ฐ์ค๋ฝ๊ฒ ์๋
๐งฉ HTML ๊ตฌ์กฐ
<div class="progress-container">
<div class="progress-bar"></div>
</div>
- progress-container: ์ ์ฒด ํ๋ก๊ทธ๋ ์ค ๋ฐ ์์ญ
- progress-bar: ์ค์ ๋๋น๊ฐ ๋ณํ๋ ๋ฐ ์์
๐จ CSS ์คํ์ผ๋ง
.progress-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 6px;
background-color: #eee;
z-index: 9999;
}
.progress-bar {
height: 100%;
width: 0%;
background-color: #3b82f6;
transition: width 0.1s ease-out;
}
- ์๋จ์ ๊ณ ์ ๋๋๋ก position: fixed ์ฌ์ฉ
- transition์ผ๋ก ๋ถ๋๋ฌ์ด ๋๋น ๋ณํ ํจ๊ณผ ์ ์ฉ
โ๏ธ JavaScript ๋ก์ง
window.addEventListener("scroll", () => {
const scrollTop = document.documentElement.scrollTop;
const scrollHeight = document.documentElement.scrollHeight;
const clientHeight = document.documentElement.clientHeight;
const scrollPercent = (scrollTop / (scrollHeight - clientHeight)) * 100;
document.querySelector(".progress-bar").style.width = scrollPercent + "%";
});
- scrollTop: ํ์ฌ ์คํฌ๋กค ์์น
- scrollHeight: ์ ์ฒด ๋ฌธ์ ๋์ด
- clientHeight: ํ๋ฉด ๋์ด
- ๊ณ์ฐ๋ scrollPercent๋ฅผ ๋ฐ ๋๋น๋ก ๋ฐ์
๐ก ํ์ฅ ์์ด๋์ด
- ์์ ๋ณ๊ฒฝ: ์คํฌ๋กค ์์น์ ๋ฐ๋ผ ์์ ๋ณํ
- ์น์ ๋ณ ์งํ๋ฅ : ํน์ ์น์ ๋ง๋ค ๋ณ๋ ๋ฐ ํ์
- ์ฑ๋ฅ ์ต์ ํ: throttle ๋๋ requestAnimationFrame ํ์ฉ
๐งพ ๋ง๋ฌด๋ฆฌ
์คํฌ๋กค ํผ์ผํธ ๊ธฐ๋ฐ ํ๋ก๊ทธ๋ ์ค ๋ฐ๋ ๋จ์ํ์ง๋ง
์ฌ์ฉ์์๊ฒ ์ฝ๊ธฐ ์งํ๋ฅ ์ ์ง๊ด์ ์ผ๋ก ๋ณด์ฌ์ฃผ๋ ํ๋ฅญํ UI์ ๋๋ค.
๋ผ์ด๋ธ๋ฌ๋ฆฌ ์์ด๋ ์ถฉ๋ถํ ๊ตฌํ ๊ฐ๋ฅํ๋ฉฐ,
๋ค์ํ ํ์ฅ ๊ธฐ๋ฅ์ผ๋ก UX๋ฅผ ๋์ฑ ํฅ์์ํฌ ์ ์์ด์.
์ด์ ์ฌ๋ฌ๋ถ์ ๋ธ๋ก๊ทธ๋ ํ๋ก์ ํธ์ ์ง์ ์ ์ฉํด๋ณด์ธ์!
๋ค์ ๊ธ์์๋ ๋คํฌ ๋ชจ๋ ํ ๊ธ ๊ธฐ๋ฅ์ ์๊ฐํ ์์ ์ด๋ ๊ธฐ๋ํด์ฃผ์ธ์. ๐