Skip to content

feat(hero-anim): Add mobile hero animation logic. Misc cleanup relate… #1025

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

Merged
merged 4 commits into from
Jun 3, 2025

Conversation

jesseaborden
Copy link

Motivation:

On smaller viewports, the hero graphic is cropped offscreen. This could cause a perceived performance issue as the animation playing offscreen is effectively an animation delay. This PR mainly adds logic to move the animation to the visible portion of the graphic. Additionally, this adds some cleanup and comments.

Modifications:

  • Added animation offset
  • Minor CSS cleanup
  • Consolidated duplicate animation logic
  • Added explanatory comments

Result:

Hero animation starts from the visible portion of the container.

// Skip to visible portion of animation when cropped on small screens
const { left, width } = animContainer.getClientRects()[0]
const offScreenDelta = Math.abs(left) / width
const initProgressVal = 0 + offScreenDelta
Copy link
Member

Choose a reason for hiding this comment

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

Can this be: const initProgressVal = offScreenDelta

Copy link
Member

Choose a reason for hiding this comment

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

Ah you want to make sure it starts from 0

Copy link
Author

@jesseaborden jesseaborden Jun 2, 2025

Choose a reason for hiding this comment

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

That was what I was thinking, but looking at it more, I don't think it's necessary. I chucked it. Thanks for catching that 🙂

@shahmishal shahmishal merged commit d55d9a0 into swiftlang:redesign Jun 3, 2025
3 checks passed
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