js ํฌ๋กฌ ๊ณต๋ฃก ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ (2)
ยท
js
์ด์ „ํŽธ์ขŒ๋กœ ์žฅ์• ๋ฌผ๋“ค์ด ๋‚˜์˜จ๋‹ค. ์ŠคํŽ˜์ด์Šค๋ฐ”๋ฅผ ๋ˆ„๋ฅด๋ฉด ๊ณต๋ฃก์ด ์ ํ”„๋ฅผ ํ•œ๋‹ค. ์žฅ์• ๋ฌผ๊ณผ ๊ณต๋ฃก์ด ์ถฉ๋Œํ•  ๊ฒฝ์šฐ ์ข…๋ฃŒ   index.html  canvas ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•˜์—ฌ ๋งŒ๋“ ๋‹ค. m" data-og-host="ranidiant.tistory.com" data-og-source-url="https://ranidiant.tistory.com/entry/js-%ED%81%AC%EB%A1%AC-%EA%B3%B5%EB%A3%A1-%EA%B2%8C%EC%9E%84-%EB%A7%8C%EB%93%A4%EA%B8%B0" data-og-url="https://ranidiant.tistory.com/entry/js-%ED%81%AC%EB%A1%AC-%EA%B3%B5%EB%A3%A1-%EA%B2%8C%EC%9E%84-%EB%A7%8C%..
js ํฌ๋กฌ ๊ณต๋ฃก ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ (1)
ยท
js
ํฌ๋กฌ ๊ณต๋ฃก๊ฒŒ์ž„ js๋กœ ๋งŒ๋“ค๊ธฐ! ๊ฒŒ์ž„์ง„ํ–‰์šฐ->์ขŒ๋กœ ์žฅ์• ๋ฌผ๋“ค์ด ๋‚˜์˜จ๋‹ค. ์ŠคํŽ˜์ด์Šค๋ฐ”๋ฅผ ๋ˆ„๋ฅด๋ฉด ๊ณต๋ฃก์ด ์ ํ”„๋ฅผ ํ•œ๋‹ค. ์žฅ์• ๋ฌผ๊ณผ ๊ณต๋ฃก์ด ์ถฉ๋Œํ•  ๊ฒฝ์šฐ ์ข…๋ฃŒ   index.html  canvas ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•˜์—ฌ ๋งŒ๋“ ๋‹ค. main.jsconst canvas = document.getElementById('canvas');const ctx = canvas.getContext('2d');canvas.width = window.innerWidth - 100;canvas.height = window.innerHeight - 100; ์ฒ˜์Œ ๋น„์–ด์žˆ๋Š” ์บ ๋ฒ„์Šค์— ํ‘œ์‹œํ•ด์ฃผ๊ธฐ ์œ„ํ•ด ๋žœ๋”๋ง ์ปจํ…์ŠคํŠธ์— ์ ‘๊ทผํ•ด์•ผํ•œ๋‹ค. getContext๊ทธ๋ ค์ง„ ๋‚ด์šฉ๋“ค์„ ๋ณด์ผ ์บ”๋ฒ„์Šค ์‚ฌ์ด์ฆˆ๋„ ์ •ํ•ด์ค€๋‹ค.    let dino = { x: 10, y: 200, w..
๋‚˜๋งŒ์˜ cli ๋งŒ๋“ค์–ด์„œ npm ํŒจํ‚ค์ง€ ๋ฐฐํฌํ•ด๋ณด๊ธฐ
ยท
js
๊ฐ€์ž…ํ•˜๊ธฐ https://www.npmjs.com/ npm | Home Bring the best of open source to you, your team, and your company Relied upon by more than 17 million developers worldwide, npm is committed to making JavaScript development elegant, productive, and safe. The free npm Registry has become the center of Java www.npmjs.com ๋จผ์ € npm ํŒจํ‚ค์ง€ ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด npm ์‚ฌ์ดํŠธ์— ๊ฐ€์ž…์ด ๋˜์–ด ์žˆ์–ด์•ผ ํ•œ๋‹ค. 2. $ mkdir [๋””๋ ‰ํ† ๋ฆฌ๋ช…] $ cd [๋””๋ ‰ํ† ๋ฆฌ๋ช…] $ npm init npm..
์›น ํŽ˜์ด์ง€์— lottie ํŒŒ์ผ ์ ์šฉํ•ด๋ณด๊ธฐ
ยท
js
๐Ÿ‘€ lottie ๋””์ž์ด๋„ˆ ๋ถ„๊ป˜์„œ lottie json์„ ๋งŒ๋“ค์–ด์ฃผ์…จ๋‹ค. โœ… html ํŽ˜์ด์ง€์— ์ ์šฉํ•ด๋ณด์ž ๐Ÿ“Œ ๊ณต์‹๋ฌธ์„œ ๋ณด๊ธฐ Lottie Docs airbnb.io ๋กœํ‹ฐ : ์—์–ด๋น„์•ค๋น„์—์„œ ๊ฐœ๋ฐœํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์• ๋‹ˆ๋ฉ”์ด์…˜์€ ๋ฐฑํ„ฐ ๊ธฐ๋ฐ˜, svg๋กœ ์ €์žฅ ๋œ๋‹ค. ๐Ÿ“Œ CDN https://cdnjs.com/libraries/lottie-web lottie-web - Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers After Effects plugin for exporting animations to SVG + JavaScript or canvas + JavaScript - Simple. Fast. Reli..
Js, lastindexof ์™€ substring ์„ ์ด์šฉํ•˜์—ฌ ํŒŒ์ผ ํ™•์žฅ์ž ์ถ”์ถœํ•˜๊ธฐ
ยท
js
function getFileExtension(fileName) { let fileLegnth = fileName.length; // ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰์˜ . ์˜ ์œ„์น˜ let lastDot = fileName.lastIndexOf('.'); // .์˜ ๋‹ค์Œ ์œ„์น˜๋ถ€ํ„ฐ ํŒŒ์ผ ์ด ๊ธธ์ด๊นŒ์ง€ let fileExtension = fileName.substring(lastDot + 1 , fileLegnth).toLowercase(); return fileExtension; } .lastIndexOf() ๋ฌธ์ž์—ด ์œ„์น˜๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. indexOf() ์™€ ๋ฐ˜๋Œ€๋กœ ๋’ค์—์„œ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜์—ฌ ์ฐพ์•„์คŒ .substring() ํŠน์ • ๋ฌธ์ž์—ด์„ ์ž˜๋ผ๋‚ด์–ด ๋ฐ˜ํ™˜ํ•œ๋‹ค. substring(start, end) ์‹œ์ž‘์œ„์น˜์—์„œ ์ข…๋ฃŒ ์œ„์น˜๊นŒ์ง€ ๋ฌธ์ž์—ด์„ ์ž๋ฅธ๋‹ค. ..
swiper ๋งˆ์šฐ์Šค ์˜ฌ๋ ธ์„ ๋•Œ ์Šฌ๋ผ์ด๋“œ ์ผ์‹œ์ •์ง€ autoplay stop
ยท
js
swiper ์Šฌ๋ผ์ด๋“œ์— ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ ธ์„ ๋•Œ ์Šฌ๋ผ์ด๋“œ ๋™์ž‘์„ ์ผ์‹œ์ ์œผ๋กœ ์ •์ง€ํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ See the Pen swiper 2 - autoplay stop on hover by jaeheekim (@jaehee) on CodePen. $('.swiper').hover(function() { swiper.autoplay.stop(); }, function(){ swiper.autoplay.start(); }); swiper.autoplay.stop() swiper.autoplay.start() ๋‘ ๊ฐœ ์†์„ฑ์„ ์ด์šฉํ•˜์—ฌ ๋งˆ์šฐ์Šค๊ฐ€ ์˜ฌ๋ ค์กŒ์„ ๋•Œ๋Š” ์Šฌ๋ผ์ด๋“œ stop() ๊ทธ ์™ธ๋Š” ๋‹ค์‹œ start๋กœ ์ ์šฉ๋˜๊ฒŒ๋” ํ•œ๋‹ค. ์ด๋•Œ ์Šฌ๋ผ์ด๋“œ ๋™์ž‘์ด ๋ฉˆ์ถœ ๋•Œ ๊ธฐ์ค€์€ ํ•˜๋‚˜ slider ๊ธฐ์ค€ ํ•˜๋‚˜์˜ ์Šฌ๋ผ์ด๋“œ ์ฒ˜์Œ๊ณผ ๋์ด ๋ชจ๋‘ ์‹œ์ž‘๊ณผ ..
js ์˜ค๋Š˜ ๋‚ ์งœ YYYY-MM-DD ๋กœ ๋‚˜ํƒ€๋‚ด๊ธฐ
ยท
js
new Date() const date = new Date(); console.log(date) //Mon Apr 03 2023 13:16:27 GMT+0900 (ํ•œ๊ตญ ํ‘œ์ค€์‹œ) ๋‚ ์งœ ๊ฐ€์ ธ์˜ค๊ธฐ const date = new Date(); const year = date.getFullYear(); const month = date.getMonth(); const day = date.getDate(); console.log(year, month, day); //2023 3 3 //ํ˜„์žฌ ๋‚ ์งœ 2023๋…„ 4์›” 3์ผ ์›” ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๊ธฐ ์œ„ํ•ด getMonth()๋ฅผ ํ™œ์šฉํ–ˆ๋‹ค. ์ฃผ์˜ํ•  ์ ์€ 1์›”์€ 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜์—ฌ 12์›”์€ 11๋กœ ๋‚˜ํƒ€๋‚˜๊ธฐ์— +1์„ ํ•ด์ค˜์•ผํ•จ YYYY-MM-DD ํ˜•์‹์œผ๋กœ const date = new Dat..
๋‘ ๊ฐœ swiper๋ฅผ ์ด์šฉํ•œ ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ํ๋ฅด๋Š” ์Šฌ๋ผ์ด๋“œ ๋งŒ๋“ค๊ธฐ
ยท
js
๊ฐ„ํ˜น ์ž‘์—…ํ•˜๋‹ค๋ณด๋ฉด ํ๋ฅด๋Š” ๋ฐฐ๋„ˆ์ผ๊นŒ ์Šฌ๋ผ์ด๋“œ์ผ๊นŒ ํ•˜๋Š” ๋ถ€๋ถ„์ด ํ•„์š”ํ•  ๋•Œ๊ฐ€ ์žˆ๋‹ค ์• ๋‹ˆ๋ฉ”์ด์…˜ ์š”์†Œ๋กœ๋„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์ง€๋งŒ swiper๋ฅผ ์ด์šฉํ•œ ์Šฌ๋ผ์ด๋“œ๋กœ ๋งŒ๋“ค์–ด๋ณด๊ธฐ smooth motion of slide ๐Ÿงต ์กฐ๊ฑด ์Šฌ๋ผ์ด๋“œ 2๊ฐœ๊ฐ€ ์„œ๋กœ ๋‹ค๋ฅธ ๋ฐฉํ–ฅ์œผ๋กœ ํ˜๋Ÿฌ๊ฐ€์•ผํ•จ ( ์˜ค๋ฅธ์ชฝ->์™ผ์ชฝ / ์™ผ์ชฝ ->์˜ค๋ฅธ์ชฝ) swiper loop ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌดํ•œ์œผ๋กœ ๋Œ์•„์•ผํ•จ ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ํ๋ฅด๋Š” ์ด๋ฏธ์ง€ ๐Ÿ”ง HTML/CSS/JS 1. HTML 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 html layout ์€ swiper js Doc ๊ธฐ๋ณธ๊ตฌ์กฐ๋ฅผ ์ ์šฉํ•˜์—ฌ ์ง„ํ–‰ํ–ˆ๋‹ค. ๋‘ ๊ฐœ์˜ ์Šฌ๋ผ์ด๋“œ๊ฐ€ ์„œ๋กœ ๋‹ค๋ฅธ ๋ฐฉํ–ฅ์œผ๋กœ ํ˜๋Ÿฌ๊ฐ€์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ltr rtl ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค. ์ปจํ…Œ์ด๋„ˆ ์š”์†Œ์— ์Šฌ๋ผ์ด๋“œ ๋ฐฉํ–ฅ์„ ์ง€์ •ํ•ด์ฃผ๋Š” ๊ฒƒ์ธ๋ฐ l..
๋ž˜๋‹ˆ
'js' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก