Skip to content

Question: How to handle sections with small height at the bottom of the page? #218

@saini-g

Description

@saini-g

First of all, thanks for the fantastic hook. Works like a charm! 👍

So, I have a page with dynamically generated sections with editable content, so the last section on the page sometimes has a small height say 100px and doesn't trigger the hook like it should be for other sections on the page
The hook works perfectly, even for the last section on the page, if it's height is large enough to be covered into the threshold value calculated using the offsetPx prop

import useScrollSpy from 'react-use-scrollspy';

// if I have 3 sections, and the height of the 3rd(last) section is small
// then activeSection value is never set to its index value i.e. 2
const activeSection = useScrollSpy({
  sectionElementRefs: sectionRefsArray,
  offsetPx: Y_OFFSET
});

Is there any way to handle this scenario?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions