LUSH renewal

ํ•˜๋Š˜ยท2022๋…„ 9์›” 3์ผ
0

ํด๋ก ์ฝ”๋”ฉ

๋ชฉ๋ก ๋ณด๊ธฐ
3/5
post-thumbnail

LUSH renewal

๐Ÿ“Ž https://github.com/eveneul/lush
๐Ÿ“Ž https://eveneul.github.io/lush

awwwards์— ์˜ฌ๋ผ์˜จ ์ˆ˜์ƒ์žฅ์„ ๋ ˆํผ๋Ÿฐ์Šค๋กœ ์ฐธ๊ณ ํ•ด์„œ ๋งŒ๋“  ๋Ÿฌ์‰ฌ ์‚ฌ์ดํŠธ ๋ฆฌ๋‰ด์–ผ์ž…๋‹ˆ๋‹ค (์ ์‘ํ˜•)

gsap, mouseover ์ด๋ฒคํŠธ ํ™œ์šฉ๊ณผ ํŠนํžˆ css ์†์„ฑ ์ค‘ mask์— ๋Œ€ํ•ด์„œ ์กฐ๊ธˆ ๋” ๊นŠ๊ฒŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ์—ˆ๋˜ ์‹œ๊ฐ„์ด์—ˆ์Šต๋‹ˆ๋‹ค

CSS์ ์ธ ์Šคํ‚ฌ๋ณด๋‹ค๋Š” gsap scrollTrigger, JQuery ๊ธฐ๋Šฅ ์œ„์ฃผ๋กœ ์Šต๋“ํ•œ ๊ฒŒ ๋งŽ์•„์„œ Jquery ๊ธฐ๋Šฅ ์œ„์ฃผ๋กœ ์ž‘์„ฑํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค

๊ณ ํ™”์งˆ ์ด๋ฏธ์ง€๋ฅผ ์–ป๋Š” ๊ฒŒ ์–ด๋ ค์›Œ์„œ ํฐ ์ด๋ฏธ์ง€์˜ ๊ฐ™์€ ๊ฒฝ์šฐ ํ™”์งˆ์ด ๋งค๋„๋Ÿฝ์ง€ ๋ชปํ•ฉ๋‹ˆ๋‹ค.. ใ… ใ… 

position: fixed๋ฅผ ์ฃผ์–ด์„œ ์Šคํฌ๋กค์„ ๋‚ด๋ฆฌ๋“  ์˜ฌ๋ฆฌ๋“  ํ•ญ์ƒ ์ƒ๋‹จ์— ์œ„์น˜ํ•˜๊ฒŒ ๊ณ ์ •ํ•ด ๋‘์—ˆ์Šต๋‹ˆ๋‹ค
๋Œ€์‹ , ํŽ˜์ด์ง€ ๋งจ ์œ„์— ์žˆ์„ ๋•Œ๋Š” background-color: transparent์„ ์ฃผ์–ด์„œ ๋ฐ”ํƒ•์— ๊น”๋ฆฐ ๋ณ„ ์•„ํ‹ฐํด์ด ๋ณด์ด๊ฒŒ๋” ์„ค์ •ํ–ˆ๊ณ ,
์Šคํฌ๋กค์„ ๋‚ด๋ฆฌ๋ฉด ํ—ค๋”๊ฐ€ ์œ„๋กœ ์˜ฌ๋ผ๊ฐ€ ์ˆจ๊ฒจ์ง€๊ณ , ์Šคํฌ๋กค์„ ์˜ฌ๋ฆฌ๋ฉด background-color๊ฐ€ ์ ์šฉ, ๋‹ค์‹œ ํ—ค๋”๊ฐ€ ๋ฐ‘์œผ๋กœ ๋‚ด๋ ค์™€ ๋ˆˆ์œผ๋กœ ๋ณด์ด๊ฒŒ๋” ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

	const headerAni = gsap
		.from('.header', {
			yPercent: -100,
			paused: true,
			duration: 0.4,
		})
		.progress(1);

	ScrollTrigger.create({
		start: 'top top',
		end: 99999,
		onUpdate: (self) => {
			self.direction === -1 ? headerAni.play() : headerAni.reverse();
		},
	});

๋จผ์ € gsap.from์„ ์ด์šฉํ•ด header ๊ธฐ๋ณธ๊ฐ’์ด y๋กœ -100%๋งŒํผ ์ด๋™ํ•ด ํ™”๋ฉด์ด ๋…ธ์ถœ๋˜์ง€ ์•Š๊ฒŒ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค
๊ทธ๋ฆฌ๊ณ  ๊ทธ๊ฒƒ์„ headerAni๋ผ๋Š” ๋ณ€์ˆ˜์— ๋‹ด์•„์„œ ์Šคํฌ๋กค์„ ์˜ฌ๋ฆฌ๋ฉด headerAni.reverse()๋กœ ํ™”๋ฉด์— ๋…ธ์ถœ๋˜๊ฒŒ,
์Šคํฌ๋กค์„ ๋‚ด๋ฆฌ๋ฉด headerAni.play()๋กœ yPercent: -100๊ฐ€ ์‹คํ–‰๋˜๊ฒŒ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค

	$(window).scroll(function (e) {
		let scrollVal = $(this).scrollTop();

		if (scrollVal <= 10) {
			gsap.to('.header', {
				'background-color': 'rgba(24,24,24, 0)',
			});
		} else {
			gsap.to('.header', {
				'background-color': 'rgba(24,24,24, 1)',
			});
		}
	});

๋˜ window์˜ ์Šคํฌ๋กค ์ˆ˜์ง ์œ„์น˜๊ฐ’์„ scrollVal์ด๋ผ๋Š” ๋ณ€์ˆ˜์— ๋‹ด์•„
scrollTop์ด 10๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์œผ๋ฉด (ํ—ค๋”๊ฐ€ ํŽ˜์ด์ง€ ๋งจ ์ƒ๋‹จ์— ์œ„์น˜ํ•˜๊ณ  ์žˆ์œผ๋ฉด) background-color์ƒ‰์ƒ์„ ํˆฌ๋ช…์œผ๋กœ,
๊ทธ๊ฒŒ ์•„๋‹ˆ๋ผ๋ฉด background-color ์ƒ‰์ƒ alpha๊ฐ’์„ 1๋กœ ์ฃผ์–ด #181818 ์ƒ‰์ƒ์ด ์ ์šฉ๋˜๋„๋ก ํ–ˆ์Šต๋‹ˆ๋‹ค

๋ฐฐ๊ฒฝ ๋ณ„ ์•„ํ‹ฐํด

์Šคํฌ๋กค์„ ์˜ฌ๋ฆฌ๊ณ  ๋‚ด๋ฆฌ๋ฉด ๋ณ„์˜ ์ž”์ƒ์ด ๋’ค์— ๋น„์ณ์ง€๊ณ , ๋งˆ์šฐ์Šค๋ฅผ ์›€์ง์˜€์„ ๋•Œ๋Š” mousemove ์ด๋ฒคํŠธ๋กœ ๋ณ„๋„ ์›€์ง์ผ ์ˆ˜ ์žˆ๊ฒŒ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค

์ผ๋‹จ ์‚ฌ์ด์ฆˆ๊ฐ€ ๋‹ค ๊ฐ™์€ ๊ฒƒ์ด ์•„๋‹Œ partice์„ particle1, particle2๋กœ ๋‚˜๋ˆ ์„œ ๋‘ ๊ฐœ์˜ ํฌ๊ธฐ๋ฅผ ๋‹ค๋ฅด๊ฒŒ ํ•ด ์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค

	let particle1 = '';
	let particle2 = '';
	for (let i = 0; i < 15; i++) {
		particle1 += `<span class="particle particle1" data-speed="${
			i + 1
		}"><i class="front"></i><i class="back"></i></span>`;
	}
	for (let i = 0; i < 15; i++) {
		particle2 += `<span class="particle particle2" data-speed="${
			i + 1
		}"><i class="front"></i><i class="back"></i></span>`;
	}
    
    $('.bg-particle').prepend(particle1);
	$('.bg-particle').prepend(particle2);

๋˜ for ๋ฐ˜๋ณต๋ฌธ์„ ํ†ตํ•ด ๊ฐ๊ฐ ์ตœ๋Œ€ 15๊ฐœ์˜ ์•„ํ‹ฐํด์„ ์„ค์ •ํ•˜๊ณ , mousemove ํ–ˆ์„ ์‹œ ์†๋„๋ฅผ ๋‹ค๋ฅด๊ฒŒ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•ด data-speed ๊ฐ’๋„ ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค

๋˜ ์ด ๋‘ ๊ฐœ์˜ particle์„ ๋ฏธ๋ฆฌ html์œผ๋กœ ์ž‘์„ฑํ•ด ๋‘” .ba-particle ์•ˆ์— ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค

	const sizeArrS = [[3, 3],[5, 5],[4, 4],[2, 2]];

	const sizeArrM = [[10, 10], [7, 7], [9, 9]];

	const small = Math.floor(Math.random() * sizeArrS.length);
	const sizeSmaollSelec = sizeArrS[small];

	const mid = Math.floor(Math.random() * sizeArrM.length);
	const sizeMidSelec = sizeArrM[mid];

ํŽ˜์ด์ง€ ๋กœ๋“œ ์‹œ๋งˆ๋‹ค particle์˜ ํฌ๊ธฐ๋ฅผ ๋‹ค๋ฅด๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ž„์˜์˜ ๋ฐฐ์—ด์„ ๋งŒ๋“ค์—ˆ๊ณ ,
Math.floor(), Math.random()์„ ํ†ตํ•ด ๋ฐฐ์—ด ์•ˆ์— ์žˆ๋Š” ์‚ฌ์ด์ฆˆ ๋ฐฐ์—ด๋“ค์ด particle์˜ ์‚ฌ์ด์ฆˆ๊ฐ€ ๋˜๋„๋ก ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค

	const winH = $(window).innerHeight();
	const winW = $(window).innerWidth();

	gsap.set('.particle1', {
		width: `${sizeSmaollSelec[0]}`,
		height: `${sizeSmaollSelec[1]}`,
		top: `random(0, ${winH})px`,
		left: `random(0, ${winW})px`,
	});
	gsap.set('.particle2', {
		width: `${sizeMidSelec[0]}`,
		height: `${sizeMidSelec[1]}`,
		top: `random(0, ${winH})px`,
		left: `random(0, ${winW})px`,
	});

window์˜ innerWidth(), innerHegiht() ๊ฐ’์„ ๊ตฌํ•ด gsap์˜ random์œผ๋กœ particle ์œ„์น˜๋ฅผ ๊ฐ๊ฐ ๋‹ค๋ฅด๊ฒŒ ์„ค์ •ํ•ด ๋‘์—ˆ์Šต๋‹ˆ๋‹ค
ํŽ˜์ด์ง€ ๋กœ๋“œ ์‹œ๋งˆ๋‹ค ๋‹ฌ๋ผ์ง€๋Š” ๊ฐ’์œผ๋กœ ๊ฐ€๋” ๊ฒน์นœ particle์ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

	$(window).mousemove(function (e) {
		$('.particle').each(function (idx, el) {
			const speed = $(this).data('speed');
			const x = ($(window).outerWidth() - e.offsetX * speed) / 350;
			const y = ($(window).outerHeight() - e.offsetY * speed) / 350;

			gsap.to(el, {
				x: x,
				y: y,
			});
		});
	});

๋จผ์ € mousemove๋ฅผ ํ•˜๋ฉด particle ๊ฐ๊ฐ data-speed ๊ฐ’์„ ์ด์šฉํ•ด์„œ ์›€์ง์ด๊ฒŒ ๋” ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค
๋ฆด๋ฆฌ๋ฐ”์ด๋ ˆ๋“œ ๋ฆฌ๋‰ด์–ผ ๋•Œ ๋ฐฐ์šด ๊ธฐ๋Šฅ์ด๋ผ์„œ ์ด๋ฒˆ ๋Ÿฌ์‰ฌ ๋ฆฌ๋‰ด์–ผ์—๋„ ์ ์šฉํ•˜๊ธฐ๊ฐ€ ์ˆ˜์›”ํ–ˆ์Šต๋‹ˆ๋‹ค

	$('body').on('mousewheel', function (e) {
		let y = e.originalEvent.wheelDelta;
		number = Math.abs(y);
		result = number > 10 ? 12 : 5;

		gsap.to('.particle .back', {
			scaleY: result,
		});

		if (y > 0) {
			gsap.set('.particle .back', {
				'transform-origin': 'center top',
				'background': 'rgb(255,255,255)',
				'background':
					'linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(159,159,159,1) 93%)',
				'border-top-left-radius': '3px',
				'border-top-right-radius': '3px',
			});
		} else {
			gsap.set('.particle .back', {
				'transform-origin': 'center bottom',
				'background': 'rgb(255,255,255)',
				'background':
					'linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(159,159,159,1) 93%)',
				'border-bottom-left-radius': '3px',
				'border-bottom-right-radius': '3px',
			});
		}

		gsap.to('.particle .back', {
			scaleY: 0,
		});
	});

๊ทธ๋ฆฌ๊ณ  body์—์„œ mousewheel ์ด๋ฒคํŠธ๋ฅผ ๋ฐœ์ƒํ–ˆ์„ ๋•Œ, e.originalEvent.wheelDelta๋กœ ๋งˆ์šฐ์Šค ํœ ์ด ์œ„๋กœ ํ–ฅํ–ˆ๋Š”์ง€, ์•„๋ž˜๋กœ ํ–ฅํ–ˆ๋Š”์ง€ ํŒ๋‹จํ•˜๋Š” y๋ผ๋Š” ๋ณ€์ˆ˜๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค

์ด y๊ฐ€ 0๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ์ž‘์œผ๋ฉด transform-origin์˜ ์†์„ฑ๊ฐ’์„ ๋ณ€๊ฒฝํ•ด์„œ ๋งˆ์น˜ ๋ณ„์˜ ์ž”์ƒ์ฒ˜๋Ÿผ ๋ณด์ด๊ฒŒ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค

๋˜ y๊ฐ€ ์Œ์ˆ˜๋ฉด ์–‘์ˆ˜๋กœ ๋ณ€ํ™˜ํ•ด ์ฃผ๋Š” Math.abs() ํ•จ์ˆ˜์— ๋‹ด๊ณ , ์ด ๊ฒฐ๊ณผ๊ฐ’์„ ์ด์šฉํ•ด ๋งˆ์šฐ์Šคํœ  ๋ฐฉํ–ฅ์— ๋”ฐ๋ผ์„œ ์ž”์ƒ ์œ„์น˜๊ฐ€ ๋ฐ”๋€Œ๊ฒŒ๋” ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค

ํŽ˜์ด์ง€ ๋กœ๋“œ ์‹œ ๋ฉ”์ธ ๋น„์ฃผ์–ผ ํ…์ŠคํŠธ ์• ๋‹ˆ๋ฉ”์ด์…˜

๋จผ์ € ํ…์ŠคํŠธ๋ฅผ CSS transform-origin์œผ๋กœ ์œ„์น˜๊ฐ’์„ ์„ค์ •ํ•ด ์ค€ ์ƒํƒœ์ž…๋‹ˆ๋‹ค

	gsap.from('.sc-visual', {
		duration: 1,
		opacity: 0,
	});

	const visualAni = gsap.timeline({
		defaults: {
			duration: 1,
			ease: 'power2.out',
		},
	});

๋จผ์ € ํƒ€์ž„๋ผ์ธ์„ ์„ค์ •ํ•ด์„œ ํ…์ŠคํŠธ -> ๋ฒ„ํŠผ -> ๋™๊ทธ๋ผ๋ฏธ ์ˆœ์œผ๋กœ ๋‚˜ํƒ€๋‚˜๊ฒŒ๋” ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค

๊ทธ๋ฆฌ๊ณ  ์ด ๋ชจ๋“  ๊ฒƒ๋“ค์ด ํˆฌ๋ช…์ธ ์ƒํƒœ์ด๊ณ  ์•„๋ž˜์—์„œ ์˜ฌ๋ผ์˜ค๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— gsap.from()์œผ๋กœ opacity: 0์„ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค

	visualAni
		.from('.sc-visual .sc-title', {
			scaleY: 5,
		})
		.from('.sc-visual .link-more', {
			duration: 0.5,
			opacity: 0,
			bottom: '200px',
		})
		.from('.rotate-article', {
			duration: 0.5,
			opacity: 0,
		})
		.to('.sc-visual .group-right .img-box', {
			opacity: 1,
		})
		.to('.sc-visual .group-right .img-box', {
			y: '15px',
			repeat: -1,
			yoyo: true,
			ease: Power1.easeInOut,
		});

gsap.timeline์„ visualAni๋ผ๋Š” ๋ณ€์ˆ˜์— ๋‹ด์•„ ํƒ€์ž„๋ผ์ธ์„ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค
์ฒซ ๋ฒˆ์งธ๋กœ ํ…์ŠคํŠธ -> ๋งํฌ ๋ฒ„ํŠผ -> ๋™๊ทธ๋ผ๋ฏธ ์•„ํ‹ฐํด -> ์˜ค๋ฅธ์ชฝ ์ด๋ฏธ์ง€ ๋ฐ•์Šค๋กœ ์„ค์ •ํ–ˆ๊ณ ,
๊ฐ๊ฐ ๊ณ ์œ ํ•œ CSS ์†์„ฑ๊ฐ’์„ ์ ์–ด ์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค

0๊ฐœ์˜ ๋Œ“๊ธ€