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

chore: update to dim bg when page scrolls beyond hero #3333

Merged
merged 2 commits into from
Jun 18, 2020

Conversation

radium-v
Copy link
Collaborator

Description

This change dims the background when the page is scrolled past the hero.

Motivation & context

To aid visual accessibility, the background needs to provide better contrast when behind the page content.

Issue type checklist

  • Chore: A change that does not impact distributed packages.
  • Bug fix: A change that fixes an issue, link to the issue above.
  • New feature: A change that adds functionality.

Is this a breaking change?

  • This change causes current functionality to break.

Adding or modifying component(s) in @microsoft/fast-components checklist

Process & policy checklist

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Comment on lines 92 to 104
setupFadeObserver() {
const observer = new IntersectionObserver(
entries => {
entries.forEach(entry => (this.faded = !entry.isIntersecting));
},
{ threshold: [0.5] }
);

const heroSection: HTMLElement = document.getElementById("hero") as HTMLElement;

observer.observe(heroSection);
Copy link
Member

Choose a reason for hiding this comment

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

🎉

{ threshold: [0.5] }
);

const heroSection: HTMLElement = document.getElementById("hero") as HTMLElement;
Copy link
Member

Choose a reason for hiding this comment

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

I don't have a good proposal, but curious if there are any issue with referencing this (assuming it's in another elements shadow DOM?)...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's actually an element in the actual DOM. Since the background itself doesn't scroll, we need to observe something that does.

Copy link
Member

Choose a reason for hiding this comment

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

party, if it's in the light dom we are good 👍

const observer = new IntersectionObserver(
entries => {
entries.forEach(entry => {
this.faded = entry.intersectionRatio < 0.5;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

@EisenbergEffect EisenbergEffect mentioned this pull request Jun 18, 2020
35 tasks
@awentzel awentzel changed the title chore: dim bg overlay when page scrolls beyond hero chore: update to dim bg when page scrolls beyond hero Jun 18, 2020
Copy link
Contributor

@SamanthaAO SamanthaAO left a comment

Choose a reason for hiding this comment

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

I ran your branch and it looks awesome!

@chrisdholt chrisdholt merged commit 7105481 into master Jun 18, 2020
@chrisdholt chrisdholt deleted the users/jokreitl/site-bg-dim branch June 18, 2020 21:35
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.

4 participants