How to get always the first intersecting observer element when scrolling down?

My problem is the following code is only properly working when scrolling up.
But when scrolling down it detects the last intersecting element instead of the top most / first.

const observer = new IntersectionObserver(entries => {
let first = null;
  entries.forEach(entry => {
        if (entry.isIntersecting) {
            const target =;
            if (target.matches('h2, h3, h4, h5, h6, p, ul')) {
                first = target;

tried as well with < 0
didn t work out…

Ok is not working because i have paragraphs and ul too but I need to know how much time is spent on them as well …