티스토리 뷰

<div class="lottie_wrap" data-type="type01">
	<div id="lottie"></div>
</div>
	setLottieAni();

	function setLottieAni() {
		const lottieContainer = document.getElementById('lottie');
		const lottieWrap = lottieContainer.closest('.lottie_wrap');

		if (!lottieWrap) return;

		// data-type 속성값 읽기
		const typeValue = lottieWrap.getAttribute('data-type');

		if (!typeValue) {
			console.warn('data-type 속성이 지정되지 않았습니다.');
			return;
		}

		const animationPath = `./lottie_${typeValue}.json`;

		// Lottie 애니메이션 로드
		bodymovin.loadAnimation({
			container: lottieContainer,
			renderer: 'svg',
			loop: true,
			autoplay: true,
			path: animationPath
		});
	}
공지사항