๋ฐ์ํ
์ ์ฒด ์ฝ๋
<body>
<style>
body {
background-color: black;
height: 6000px;
}
div {
margin-top: 1000px;
color: white;
text-align: center;
opacity: 0;
transition: all 1s;
transform: rotate(-720deg);
}
</style>
<div><h1>์๋
ํ์ธ์.</h1></div>
<div><h1>์คํฌ๋กค๋ฐ ์ด๋ฒคํธ ํ
์คํธ</h1></div>
<div><h1>observer ํ
์คํธ์
๋๋ค.</h1></div>
<div>
<img
src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAJ4AqAMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAAAAAAAAAFAQIDBAYAB//EADkQAAEEAQMBBgQDBwMFAAAAAAEAAgMEEQUSITEGEyJBUWEUMnGhI4GRFUJScrHR8BbB8Qczc4Lh/8QAGQEAAwEBAQAAAAAAAAAAAAAAAQIDBAAF/8QAIREAAgIDAAIDAQEAAAAAAAAAAAECEQMSIQQxEyJBFFH/2gAMAwEAAhEDEQA/AI+zdmvF/wB5rSmdonVpXOdDgIFXMjXeA/ollme75+Vv0ewu61K5anMXYTgFUgSser9E+NqHNVus7Y5Brg8H09M0CzHFE3kdFZ1q9G6L5h5rEVNVdG3APCbc1V8jcF3H1WT4m5G35ILoP1SRr5XY5Ql4VueTe5ViFrSMM5WyLC4BSbVwanoSy5pcjYbLJHfK0heif6yrs0/uw0dMLzJp2jITzI7btyozxKXstDNqqLGsXTdsOkACFkKdwTCFVcJSbbsiwk2qTCTCIKI8IjpF9+n2mTRnBaqOEqV9VBTp2G+0WvS6s8OfgYHAHRcgblyCikFybNP2W/ZzY7PxgLpy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ujbic6lGIZseENOG/0U/6oXQ/wTqzEQjL+Fuuz2pQQVdrsblinwSRSmORnjZ1Cs13yA7WnCOaG6KYMii/say1Ky5Y8IXIfWPdNbIXE5OD9Vyx60elGao1VqNrouQFmbMH4m5gWlsglu0HKpfDF3kFKDBG6BffSiPaTnj6oW+oPRaY1D6BV3VCP3VeMkvQJRcgB8GFJFQL5GjxZRptUfwn9ERo0WMPePHI6ZTvKqIPGWqELKtRkeMY9VDPCNzlJNO1UZL4id4yCsj6WhGhj3bE2Vsc8bmPGQeEtva9vexkFrvRV4pfdGI7RnLtd1a06FwPscdQtFo1dleAZH4jvE4/7KtqsbLElZwHjDsfUK9E1zeipYsnaoJsTmu2vx5qOsS7qq0VsPsO9nYCUlRD2j0xtmP4gdR1Q3s3SjbadM4cxjLfutTG9kjNpGWnqCqbaorWy9mAxwxhVjkag4knjW1kM5c9zn54aCcIDPqNohwYRE13TA5P5rTsa1ry1w+bhCrlUMnc3A27iW8LsTV9HyKT9Gc7lvGOfyUsNbc7gE/RGm1vqpG12+hH0Wh5SKwg4DDdh34zn2ykRcVmO8lylsi6gwm96UA+imIB+YApwYFkLuRFtz0TTEHdVNknpgJcn2XWLbIRE0dQpnjbEkA3H39UrvFEuAwPZmPmg12cordCz9565I0xSJ9N1NsDnQznEL+h/hKlmeWeJpy31HRZW9YdH0Q19+T5cu2+mVRRsMo/psYL7JbzGNdkDJ5RyO4wdRhea1r74Jg9nJZ6+a1mn2/i6/ehpafMHlFr/AAm4pmurWG89OOvss9UsnvHO9yoLV51aLum53SjG70BSUUKFjE01KcuROQNcAMc+vog+nN8bUUkLj0OEgkl0hdjvU+WONzmue1K2IB24uJUhDXeq6ziqa7D5fqubWarIaD/9Tg0bl2zO9ETImfw/Zcl3lchbDTP/2Q=="
alt="cute cat"
</div>
<script>
let observer = new IntersectionObserver((e) => {
e.forEach((entry) => {
// ํ๋ฉด์ ๋ณด์ผ๋๋ง ์คํ
if (entry.isIntersecting) {
entry.target.style.opacity = 1;
entry.target.style.transform = "rotate(0deg)";
}
entry.intersectionRatio; // ํ๋ฉด์ ๋ช ํผ์ผํธ๊ฐ ๋ณด์ด๋์ง
});
});
let div = document.querySelectorAll("div");
observer.observe(div[0]);
observer.observe(div[1]);
observer.observe(div[2]);
observer.observe(div[3]);
</script>
</body>
์๋กญ๊ฒ ์๊ฒ ๋ ์
1. IntersectionObserver ๋ ํ๋ฉด์ ๋ณด์ผ๋, ํ๋ฉด์์ ๋๊ฐ ๋ 2๋ฒ ์คํ๋๋ค.
๊ทธ๋์ ํ๋ฉด์ ๋ณด์ผ ๋๋ง ์คํํ๊ณ ์ถ๋ค๋ฉด ์๋์ ์ฝ๋์ฒ๋ผ isIntersection ์ ํ์ฉํด์ผํ๋ค.
if (entry.isIntersecting) {
}
2. intersectionRatio ๋ ํ๋ฉด์ ๋ช ํผ์ผํธ๊ฐ ๋ณด์ด๋์ง ์ปจํธ๋กค ํ ์ ์๋ค.
๋ฐ์ํ
'๐ฅFrontEnd' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
jest ์ฉ๋๋ณ ๋งค์ฒ ์์๋ณด๊ธฐ (0) | 2024.09.21 |
---|---|
Jest ๊ธฐ๋ณธ ๊ณต๋ถํ๊ธฐ, ์ฝ๊ฒ Jest๋ก ํ ์คํธํ๋ ์ต์คํ ์ ์ถ์ฒ (0) | 2024.09.09 |
์น ์ฑ๋ฅ ์ต์ ํ๋ฅผ ์ํ ๋๊ตฌ ์ถ์ฒ (0) | 2024.07.27 |
jest, beforeAll, afterAll (0) | 2023.05.01 |
jest ๊ธฐ๋ณธ ๊ณต๋ถ (0) | 2023.04.28 |