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

Scroll calendar to current week on first load #276

Conversation

JSn1nj4
Copy link

@JSn1nj4 JSn1nj4 commented Apr 29, 2024

The basic requirements are listed here

  • Scroll to current on page load
  • Reset to top on next/previous
  • Only do this on the month view

Attempting to move to the current week happens from Full Calendar's loading hook, which seems to fire both when loading and after loading is completed.

It will only happen on first render using a local var. This is because this hook is fired on first load and every time someone navigates using the calendar's "Next"/"Previous" buttons.

Re-centering also doesn't happen if someone manually navigates back to the current month instead of reloading the page.

Resolves #253

@JSn1nj4 JSn1nj4 added the enhancement New feature or request label Apr 29, 2024
@allella
Copy link
Member

allella commented Apr 30, 2024

Thanks. Sounds like a good approach.

@zach2825 is doing a good deal of front-end these days, so perhaps he can give this one a review too as my JS was never that great and I'm rusty to boot.

@allella allella requested a review from zach2825 April 30, 2024 03:35
@JSn1nj4
Copy link
Author

JSn1nj4 commented Apr 30, 2024

Ah ok, my bad. I'll tag Zach next time then instead for these frontend ones.
Thanks!

@bogdankharchenko
Copy link
Collaborator

@JSn1nj4 I am not sure what is happening here - I pulled the branch down but not sure what the effect should be

@JSn1nj4
Copy link
Author

JSn1nj4 commented Apr 30, 2024

@bogdankharchenko it's just making the calendar view move down to the current week on initial render instead of sticking to the top of the month.

This does depend on the height of the calendar view and viewport though. The more of the month that shows vertically, or the closer to the top of the month the current week is, the less scroll there may be.

I'm going to check if there's an easy way to add a light scroll animation in a minute.

Thanks @zach2825 for the suggestion
@JSn1nj4
Copy link
Author

JSn1nj4 commented Apr 30, 2024

Thanks @zach2825 for the smooth scroll suggestion. Didn't realize scrollTo() could do that natively. 🙂

@bogdankharchenko how does this look?

@bogdankharchenko
Copy link
Collaborator

Thanks @zach2825 for the smooth scroll suggestion. Didn't realize scrollTo() could do that natively. 🙂

@bogdankharchenko how does this look?

Functionally, looks good but wasn't the one making this request.

👍

Copy link
Collaborator

@zach2825 zach2825 left a comment

Choose a reason for hiding this comment

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

🎆 Looks really good!

@allella allella merged commit ded87a9 into hackgvl:develop May 1, 2024
1 check passed
@JSn1nj4 JSn1nj4 deleted the feature/253-jump-calendar-to-current-week-on-load branch May 3, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

Center the Calendar to the Current Week
4 participants