JSFiddle - React, Tailwind, and code Playground

by sandro_paganotti

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <section class = 'section1'></section>
    <section></section>
    <section></section>
    <section></section>
    <section></section>
    <section></section>
</body>
</html>

CSS

body{
    padding: 0;
    margin: 0;
}

section{
    height: 100vh;
    width: 100%;
}
section:nth-child(odd){
    background: lightcoral;
}

JavaScript

const sectionOne = document.querySelector('.section1');
const options = {};

const observer = new IntersectionObserver(function
(entries, observer){
    entries.forEach(entry => {
        console.log(entry);
    });
}, options);

observer.observe(sectionOne);