Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset config #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

JohnMealy23
Copy link

I've added a configuration object to your module, allowing for offset borders to the viewport.

One potential use case - an engineer may have a sticky top nav that overlaps the element in question. The height of that topnav could be entered as such:

const topNavHeight = document.getElementById('topNav').style.height;
const percentViewable = vertical(el, { offsetHeight: topNavHeight }).value;

I've taken care to add supporting unit tests, and to take into account offsets when calculating percent in-view.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling aaf887e on JohnMealy23:offsetConfig into ** on kahwee:master**.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants