<div id="intro-main">
    <p>Elements based scroll event triggerring</p>
  </div>
  <ul id="list-item-wrapper">

    <li class="list-item">Dog</li>
    <li class="list-item">Cat</li>
    <li class="list-item">Elephant</li>
    <li class="list-item">Giraffe</li>
    <li class="list-item">Lion</li>
    <li class="list-item">Tiger</li>
    <li class="list-item">Zebra</li>
    <li class="list-item">Kangaroo</li>
    <li class="list-item">Dog</li>
    <li class="list-item">Cat</li>
    <li class="list-item">Elephant</li>
    <li class="list-item">Giraffe</li>
    <li class="list-item">Lion</li>
    <li class="list-item">Tiger</li>
    <li class="list-item">Zebra</li>
    <li class="list-item">Kangaroo</li>
    <li class="list-item">Dog</li>
    <li class="list-item">Cat</li>
    <li class="list-item">Elephant</li>
    <li class="list-item">Giraffe</li>
    <li class="list-item">Lion</li>
    <li class="list-item">Tiger</li>
    <li class="list-item">Zebra</li>
    <li class="list-item">Kangaroo</li>
    <li class="list-item">Dog</li>
    <li class="list-item">Cat</li>
    <li class="list-item">Elephant</li>
    <li class="list-item">Giraffe</li>
    <li class="list-item">Lion</li>
    <li class="list-item">Tiger</li>
    <li class="list-item">Zebra</li>
    <li class="list-item">Kangaroo</li>

  </ul>
/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
  display: block;
}

body {
  line-height: 1;
}

ol,
ul {
  list-style: none;
}

blockquote,
q {
  quotes: none;
}

blockquote:before,
blockquote:after,
q:before,
q:after {
  content: '';
  content: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

body {
  background-color: #111111;
  font-family: sans-serif;
}

#main-img-wrapper {
  padding-top: 139px;
  text-align: center;
}

#intro-main {
  display: flex;
  flex-direction: column;
  margin: 54px auto 140px;
  width: 300px;
  align-items: center;
  color: white;
  font-size: 40px;
  font-weight: 500;
  gap: 20px;
}

#join-us-text {
  margin-top: 73px;
  font-size: 16px;
  font-weight: 400;
  opacity: .6;
}

#intro-main p {
  text-align: center;
}

@keyframes upAndDown {
  0% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }

  100% {
    transform: translateY(0);
  }
}

#down-arrow-icon {
  width: 33px;
  animation: upAndDown 1s infinite;
}

#list-item-wrapper {
  margin: 0 auto 0;
  width: 383px;
}

.list-item {
  /* display: inline; */
  font-size: 48px;
  font-weight: 600;
  word-break: keep-all;
  white-space: nowrap;
}

.list-item#on {
  color: white;
}

#intro-main {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 0;
  height: 100vh;
}

.list-item-wrapper {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0;
  margin: 0;
  padding: 0;
}
const documentHeight = document.body.scrollHeight;

  const introMain = document.getElementById("intro-main");
  const introMainHeight = introMain.offsetHeight;

  const listWrapper = document.getElementById("list-item-wrapper");
  const listWrapperHeight = listWrapper.clientHeight;
  const listItems = document.querySelectorAll('.list-item')

  // Scroll event start point
  const listStyleChangeStartY = introMainHeight;;
  // Scroll event end point
  const listStyleChangeEndY = documentHeight;
  // Real start point for scroll event
  const realStartPointY = listStyleChangeStartY / 2;

  // Elements height
  let division = ((listStyleChangeEndY - listStyleChangeStartY) / listItems.length)

  // Expand scrollabe area
  listWrapper.style.marginBottom = `${listWrapperHeight / 2}px`

  window.addEventListener("scroll", () => {
    // Remove id attribute
    if (document.getElementById("on")) document.getElementById("on").removeAttribute("id")

    // Add id attribute to the element that is in the scroll area
    if (window.scrollY > realStartPointY && window.scrollY < listStyleChangeEndY) {
      const scrollPosition = window.scrollY - realStartPointY;
      const targetIndex = Math.floor(scrollPosition / division);

      // Add id attribute to the element that is in the scroll area
      if (targetIndex >= 0 && targetIndex < listItems.length) {
        listItems[targetIndex].id = "on";
      }
    }
  })

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.