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

feat: hook to ease scroll to an element #226

Merged
merged 1 commit into from
Aug 11, 2023
Merged

Conversation

DiogoSoaress
Copy link
Member

@DiogoSoaress DiogoSoaress commented Aug 10, 2023

What it solves

Resolves #227

How this PR fixes it

When opening the Core page, smoothly scrolls to the masthead section.
The target scroll position, ease and duration are reviewed by the design team.

@github-actions
Copy link

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

Branch preview

✅ Deployed to dev:

https://safe-web-landing.dev.5afe.dev

@DiogoSoaress DiogoSoaress marked this pull request as ready for review August 11, 2023 08:53
Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

Is this chatgpt-generated? Why are you not just using scrollIntoView with behavior: 'smooth'?

Also, on mobile it doesn't scroll all the way. The masthead is cut off at the bottom.

@DiogoSoaress
Copy link
Member Author

I tried first with the behavior: 'smooth' but I wanted a different ease function to give an acceleration effect.

on mobile it doesn't scroll all the way. The masthead is cut off at the bottom

It was requested to not scroll the masthead all the way to the top (that's why I'm subtracting a factor of 0.2 * window.innerHeight to the masthead section top)

Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

I'll approve but I would recommend looking into adding Framer Motion to this project as it's likely to have more custom animations in future.
And there's a plugin for Motion specifically for animated scrolling: https://github.com/breadadams/scroller-motion

@DiogoSoaress
Copy link
Member Author

Thanks for the references! I will definitely look into those as I agree the project will have more custom animations.

@DiogoSoaress DiogoSoaress merged commit ceb3dc4 into main Aug 11, 2023
5 checks passed
@DiogoSoaress DiogoSoaress deleted the masthead-scroll branch August 11, 2023 09:31
@github-actions github-actions bot locked and limited conversation to collaborators Aug 11, 2023
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.

[Whitepaper launching] Smooth scroll to the "Launching Protocol" section
2 participants