๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ’ฌ/ใ…ใ……ใ…Œใ…‹ใ…ใ…… ์ฑŒ๋ฆฐ์ง€

ํŒจ์ŠคํŠธ ์บ ํผ์Šค ์ฑŒ๋ฆฐ์ง€ 11์ผ์ฐจ

๐Ÿ”ฎ

11์ผ์ฐจ

 

Part 1. HTML/CSS/JS๋กœ ๋งŒ๋“œ๋Š” ์Šคํƒ€๋ฒ…์Šค ์›น์‚ฌ์ดํŠธ

Ch 10. ์Šคํƒ€๋ฒ…์Šค ์˜ˆ์ œ

 


 

Ch 10. ์Šคํƒ€๋ฒ…์Šค ์˜ˆ์ œ

 

 

์ฃผ์ œ

 

  • ํ—ค๋”์™€ ๋“œ๋กญ๋‹ค์šด ๋ฉ”๋‰ด

 

 

์ฃผ์š” ๋‚ด์šฉ

 

์‹ค์Šต ํ™”๋ฉด

 

 

์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ ๋œ ๋‚ด์šฉ

 

 top์ด๋‚˜ bottom ์†์„ฑ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„ ์ˆ˜์ง ์œ„์น˜ ๊ฐ’์ด ์—†๋‹ค๋ฉด, ์š”์†Œ์˜ ์›๋ž˜ ์œ„์น˜๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•œ๋‹ค.

 ๋งŒ์•ฝ position: absolute;๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค๋ฉด, (์œ„์น˜์ƒ) ๋ถ€๋ชจ ์š”์†Œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํ•˜๋ฏ€๋กœ ํ™”๋ฉด์˜ ๋ทฐํฌํŠธ ์ขŒ์šฐ ๋๊นŒ์ง€ ๋Š˜์–ด๋‚  ์ˆ˜ ์—†๊ฒŒ ๋œ๋‹ค.

 

 ๐Ÿ”— BEM(Block Element Modifier) : HTML ํด๋ž˜์Šค ์†์„ฑ์˜ ์ž‘๋ช…๋ฒ•

  • ์š”์†Œ__์ผ๋ถ€๋ถ„
  • ์š”์†Œ--์ƒํƒœ

 

 ์ผ๋ฐ˜์ ์œผ๋กœ block ์š”์†Œ๋Š” width๋ฅผ ์ตœ๋Œ€ํ•œ ๋Š˜์–ด๋‚˜๋ ค๊ณ  ํ•˜์ง€๋งŒ, position fixed์™€ absolute ์š”์†Œ๋Š” ์ตœ์†Œํ•œ ์ค„์–ด๋“ค๋ ค๊ณ  ํ•œ๋‹ค.

์ด ๋ฐฉ๋ฒ•์œผ๋กœ ํ•ด๊ฒฐ!

 

 ๐Ÿ”— Lodash JS ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ : ์Šคํฌ๋กค์ด ์ง€๋‚˜์น˜๊ฒŒ ์ž์ฃผ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์„ ์กฐ์ ˆ(throttle, ์ผ๋ถ€๋Ÿฌ ๋ถ€ํ•˜๋ฅผ ์คŒ)

https://cdnjs.com/libraries/lodash.js

 

lodash.js - Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers

A utility library delivering consistency, customization, performance, & extras. - Simple. Fast. Reliable. Content delivery at its finest. cdnjs is a free and open-source CDN service trusted by over 12.5% of all websites, serving over 200 billion requests e

cdnjs.com

ํ™”๋ฉด์ด ์Šคํฌ๋กค ๋  ๋•Œ ์‹คํ–‰๋˜๋Š” ํ•จ์ˆ˜์˜ ๊ฐœ์ˆ˜๋ฅผ _.throttle()์ด๋ผ๋Š” ๋ฉ”์†Œ๋“œ ๊ธฐ๋Šฅ์„ ํ†ตํ•ด์„œ ์ผ์ • ์‹œ๊ฐ„์— ํ•œ ๋ฒˆ์”ฉ๋งŒ ์‹คํ–‰๋˜๋„๋ก ์ œํ•œ์„ ๊ฑด๋‹ค. => ์„ฑ๋Šฅ up

._throttle(ํ•จ์ˆ˜, ์‹œ๊ฐ„)

 

 ๐Ÿ”— GSAP JS ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ : ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ฒ˜๋ฆฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

https://cdnjs.com/libraries/gsap

 

gsap - Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers

GSAP is a JavaScript library for building high-performance animations that work in **every** major browser. Animate CSS, SVG, canvas, React, Vue, WebGL, colors, strings, motion paths, generic objects...anything JavaScript can touch! No other library delive

cdnjs.com

gsap.to(์š”์†Œ, ์ง€์†์‹œ๊ฐ„, ์˜ต์…˜)

 

๐Ÿ”— Lodash, GSAP ์†Œ์Šค ์ฝ”๋“œ

//? ํŽ˜์ด์ง€ ์Šคํฌ๋กค์— ๋”ฐ๋ฅธ ์š”์†Œ ์ œ์–ด
// ํŽ˜์ด์ง€ ์Šคํฌ๋กค์— ์˜ํ–ฅ์„ ๋ฐ›๋Š” ์š”์†Œ๋“ค์„ ๊ฒ€์ƒ‰!
const badgeEl = document.querySelector("header .badges");
const toTopEl = document.querySelector("#to-top");
// ํŽ˜์ด์ง€์— ์Šคํฌ๋กค ์ด๋ฒคํŠธ๋ฅผ ์ถ”๊ฐ€!
// ์Šคํฌ๋กค์ด ์ง€๋‚˜์น˜๊ฒŒ ์ž์ฃผ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์„ ์กฐ์ ˆ(throttle, ์ผ๋ถ€๋Ÿฌ ๋ถ€ํ•˜๋ฅผ ์คŒ)
window.addEventListener(
  "scroll",
  _.throttle(function () {
    // ํŽ˜์ด์ง€ ์Šคํฌ๋กค ์œ„์น˜๊ฐ€ 500px์ด ๋„˜์œผ๋ฉด.
    if (window.scrollY > 500) {
      // Badge ์š”์†Œ ์ˆจ๊ธฐ๊ธฐ!
      gsap.to(badgeEl, 0.6, {
        opacity: 0,
        display: "none",
      });
      // ์ƒ๋‹จ์œผ๋กœ ์Šคํฌ๋กค ๋ฒ„ํŠผ ๋ณด์ด๊ธฐ!
      gsap.to(toTopEl, 0.2, {
        x: 0,
      });

      // ํŽ˜์ด์ง€ ์Šคํฌ๋กค ์œ„์น˜๊ฐ€ 500px์ด ๋„˜์ง€ ์•Š์œผ๋ฉด.
    } else {
      // Badge ์š”์†Œ ๋ณด์ด๊ธฐ!
      gsap.to(badgeEl, 0.6, {
        opacity: 1,
        display: "block",
      });
      // ์ƒ๋‹จ์œผ๋กœ ์Šคํฌ๋กค ๋ฒ„ํŠผ ์ˆจ๊ธฐ๊ธฐ!
      gsap.to(toTopEl, 0.2, {
        x: 100,
      });
    }
  }, 300)
);

 

 

๋Š๋‚€์ 

 

 ์œ ์šฉํ•œ JS ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์•Œ์•„๊ฐˆ ์ˆ˜ ์žˆ์—ˆ๋‹ค. ์ดˆ๋ฐ˜ ๊ฐ•์˜์— ๋‚˜์™”๋˜ css reset cdn์€ ๊ฐœ์ธ์ ์œผ๋กœ ์ ์šฉ๋˜์ง€ ์•Š๋Š” ๋ถ€๋ถ„์ด ๋งŽ์€ ๊ฑฐ ๊ฐ™์•„์„œ..! ๊ฐœ์ธ ํ”„๋กœ์ ํŠธํ•  ๋•Œ๋Š” ์‚ฌ์šฉ ์•ˆ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.

 


 

๋ณธ ํฌ์ŠคํŒ…์€ ํŒจ์ŠคํŠธ์บ ํผ์Šค ํ™˜๊ธ‰ ์ฑŒ๋ฆฐ์ง€ ์ฐธ์—ฌ๋ฅผ ์œ„ํ•ด ์ž‘์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

 

#ํŒจ์ŠคํŠธ์บ ํผ์Šค

#ํŒจ์บ ์ฑŒ๋ฆฐ์ง€

#์ง์žฅ์ธ์ธ๊ฐ•

#์ง์žฅ์ธ์ž๊ธฐ๊ณ„๋ฐœ

#ํŒจ์ŠคํŠธ์บ ํผ์Šคํ›„๊ธฐ

#ํ•œ_๋ฒˆ์—_๋๋‚ด๋Š”_ํ”„๋ก ํŠธ์—”๋“œ_๊ฐœ๋ฐœ_์ดˆ๊ฒฉ์ฐจ_ํŒจํ‚ค์ง€_Online

 

https://bit.ly/37BpXiC

 

ํŒจ์ŠคํŠธ์บ ํผ์Šค [์ง์žฅ์ธ ์‹ค๋ฌด๊ต์œก]

ํ”„๋กœ๊ทธ๋ž˜๋ฐ, ์˜์ƒํŽธ์ง‘, UX/UI, ๋งˆ์ผ€ํŒ…, ๋ฐ์ดํ„ฐ ๋ถ„์„, ์—‘์…€๊ฐ•์˜, The RED, ๊ตญ๋น„์ง€์›, ๊ธฐ์—…๊ต์œก, ์„œ๋น„์Šค ์ œ๊ณต.

fastcampus.co.kr