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

Creates script to preserve menu's scroll position on click. #75

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oilsinwater
Copy link
Collaborator

@oilsinwater oilsinwater commented Sep 19, 2023

Should resolve issue #64

@SaptakS @Erioldoesdesign I prioritized creating a script for this because it's actually a bit challenging to browse the site otherwise.

@oilsinwater oilsinwater requested a review from SaptakS September 19, 2023 17:58
@oilsinwater oilsinwater self-assigned this Sep 19, 2023
@netlify
Copy link

netlify bot commented Sep 19, 2023

Deploy Preview for subtle-medovik-58f1c6 ready!

Name Link
🔨 Latest commit 62c600f
🔍 Latest deploy log https://app.netlify.com/sites/subtle-medovik-58f1c6/deploys/6509e132af145a0008d384a4
😎 Deploy Preview https://deploy-preview-75--subtle-medovik-58f1c6.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@oilsinwater oilsinwater marked this pull request as draft September 19, 2023 17:59
@oilsinwater
Copy link
Collaborator Author

@SaptakS I switched this to draft--there's some jitter and I'm not confident it works. I might just need to clear my cache--will dbl check

// Attaches an event listener to the window's beforeunload event to store the scroll position
window.addEventListener('beforeunload', storeScrollPosition);
// Calls the restoreScrollPosition function when the page loads
window.addEventListener('load', restoreScrollPosition);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Try maybe DOMContentLoaded. Also, you can put this JS in head instead of end of body, to make this JS run at the very beginning. These 2 might help reduce the jump timing. There will still always be a microsecond of jump between DOM being loaded and JS being executed.

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.

2 participants