Skip to content

Instantly share code, notes, and snippets.

View GiPyoo's full-sized avatar
๐Ÿ˜œ
Be Better

GiPyoo GiPyoo

๐Ÿ˜œ
Be Better
  • ECONOVATION
  • ์ „๋‚จ๋Œ€ํ•™๊ต
View GitHub Profile
@skt-t1-byungi
skt-t1-byungi / ์ฝ”๋ฃจํ‹ด.md
Last active September 2, 2022 11:33
์ฝ”๋ฃจํ‹ด์„ค๋ช…

์ œ๋„ค๋ ˆ์ดํ„ฐ, ๋˜๋Š” asyncํ•จ์ˆ˜์™€ ๊ฐ™์€ ์ฝ”๋ฃจํ‹ด์€ ๋กœ์ง์„ ์ผ์‹œ์ค‘๋‹จ(yield๋˜๋Š” await์„ ํ†ตํ•ด)ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ์กด์˜ ์ฝœ๋ฐฑํŒจํ„ด์—์„  pause๋œ ์ƒํƒœ๋ฅผ ๊ตฌ๋ถ„ ํ•˜๊ธฐ ์œ„ํ•œ ํ”Œ๋ž˜๊ทธ ๋ณ€์ˆ˜๊ฐ€ ํ•„์š”ํ•œ๋ฐ ์ฝ”๋ฃจํ‹ด ํŒจํ„ด์—์„  (์ผ์‹œ์ค‘๋‹จํ•  ์ˆ˜ ์žˆ๋Š”)์ œ์–ดํ๋ฆ„์œผ๋กœ์จ ๋Œ€์‹  ํ‘œํ˜„๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

BEFORE:

const el = document.querySelector('.draggable')

let isTouching = false // <= ํ”Œ๋ž˜๊ทธ๋ณ€์ˆ˜, ๋กœ์ง์ด ๋ณต์žกํ•  ์ˆ˜๋ก ๋Š˜์–ด๋‚จ