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

Add support for progress events #1

Closed
rdmurphy opened this issue Mar 18, 2022 · 1 comment
Closed

Add support for progress events #1

rdmurphy opened this issue Mar 18, 2022 · 1 comment

Comments

@rdmurphy
Copy link
Owner

rdmurphy commented Mar 18, 2022

This should be an opt-in feature that is expected to be flagged on every instance of scroll-scene that wants them to activate.

<scroll-scene progress></scroll-scene>
<!-- may be better to use data attributes -->
<scroll-scene data-progress></scroll-scene>

This flag would cause an instance of scroll-scene to interface with the global observer and set up a scroll listener for calculating scroll depth for that element once it enters the view and removes the listener when it exits the view.

The user would still be expected to set up their own listener for this event to react to it.

document.addEventListener('scroll-scene-progress', ({ detail }) => {
  const element = detail.element;
 const progress = detail.progress;
  // do what you need to do
});
@rdmurphy
Copy link
Owner Author

Added via 1f61d39.

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

No branches or pull requests

1 participant