Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

refactor: Use IntersectionObserver in Layout component #168

Merged
merged 1 commit into from
Mar 8, 2019

Conversation

ollelauribostrom
Copy link
Contributor

This might need a bit of tweaking so consider it a WIP.

The idea is that instead of calculating the hero offset in each animation frame - we can use the IntersectionObserver API. We are notified each time the intersection changes and when a .side-nav__title intersects with the hero banner, we apply some white color. Should offer some performance benefits and might also help solve #86.

Seems like the browser support is pretty good, so this should work out of the box in most browsers. What are your thoughts on this?

@antsmartian
Copy link

+1 on using the observer, but I'm not sure what is the minimum browser version we are target for our website (because as you mentioned observer wont work in some browsers)?

@MylesBorins
Copy link
Contributor

/gcbrun

eventual staging example will be on https://storage.googleapis.com/staging.nodejs.dev/1001a01/index.html

@sagirk
Copy link
Contributor

sagirk commented Mar 4, 2019

+1 on using the observer, but I'm not sure what is the minimum browser version we are target for our website (because as you mentioned observer wont work in some browsers)?

Yeah, I'd suggest keeping both the implementations, preferring IntersectionObserver when available and falling back to calculating the hero offset on each animation frame on older browsers.

@ollelauribostrom
Copy link
Contributor Author

Thanks for the input @antsmartian, @BeniCheni, @sagirk. I'm holding off with this one until we have merged #157 🙂Nice idea to keep the current implementation as a fallback 👍

@sagirk
Copy link
Contributor

sagirk commented Mar 7, 2019

@ollelauribostrom #157 is merged. You may want to rebase against the latest master.

@ollelauribostrom
Copy link
Contributor Author

@sagirk Rebased and added back the old implementation as fallback.

Copy link
Contributor

@BeniCheni BeniCheni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ollelauribostrom , LGTM after your rebase and update. 🎊

P.S.: per .querySelector('.side-nav'); and .querySelectorAll('.side-nav__title');. Could refs be used instead of class selector? (curious about your thoughts if a follow-up refactoring would improve; I could tinker around)

Copy link
Contributor

@sagirk sagirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉

Great job, @ollelauribostrom! Thanks! ❤️

@sagirk sagirk merged commit a693167 into nodejs:master Mar 8, 2019
@sagirk
Copy link
Contributor

sagirk commented Mar 8, 2019

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

Successfully merging this pull request may close these issues.

5 participants