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

Adding a scroll behavior for a button #247

Merged
merged 1 commit into from
Apr 18, 2024
Merged

Conversation

OliaKr
Copy link
Contributor

@OliaKr OliaKr commented Apr 1, 2024

Added a scroll behavior for a button in WhatNow component to Paths.

Copy link

vercel bot commented Apr 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
maakaf-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 1, 2024 4:04pm

top: targetElement.offsetTop,
behavior: 'smooth',
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You dont need to use the window object for this.

You can use the targetElement (you know its an html elment and it exist):

targetElement.scrollIntoView({ behavior: 'smooth', block: 'start' });

const targetId = e.currentTarget.getAttribute('href');
if (targetId) {
const targetElement = document.querySelector(targetId) as HTMLElement; // Type assertion
if (targetElement) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the comment please

Copy link
Contributor

@Tamir198 Tamir198 left a comment

Choose a reason for hiding this comment

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

Good job generallyI, left you some comments.

@Darkmift Darkmift merged commit e061b18 into Maakaf:main Apr 18, 2024
5 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.

3 participants