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

popState scroll position bug #164

Closed
MMasey opened this issue Jun 21, 2019 · 3 comments
Closed

popState scroll position bug #164

MMasey opened this issue Jun 21, 2019 · 3 comments

Comments

@MMasey
Copy link

MMasey commented Jun 21, 2019

Hello,

I'm experience an off bug in Swup v2 in that when a person uses the browser back and forward history buttons they aren't taken to the correct previous scroll location. According to the docs the animateHistoryBrowsing default value is false which should mean that the browser handles all of the history related scroll positions but it keeps scrolling to the locations that the person was first on they they either visited the page, or reloaded it.

My current config is as followed.

const swup = new Swup({
	containers: ["#swup"],
	animationSelector: '[class*="swup-swipe"]',
	linkSelector: `a[href^="${window.location.origin}"]:not([data-no-swup]):not([target="_blank"]), a[href^="/"]:not([data-no-swup]):not([target="_blank"]), a[href^="#"]:not([data-no-swup]):not([target="_blank"])`,
	plugins: [
		new SwupGaPlugin(),
		new SwupPreloadPlugin(),
		new SwupFormsPlugin(),
		new SwupScrollPlugin({
			animateScroll: false
		})
	]
};);

I have tried disabile all the other JavaScript that is used on the site, as well as removing all of the plugins and the issue still seems to present itself. Has anyone else experienced this. I can't figure out if it's a bug with the core Swup code, or user error on my part.

Edit: Forgot to mention, i'm using the latest version of Chrome on Windows 10.

Thanks

@MMasey MMasey changed the title Browser history scroll position bug popState scroll position bug Jun 21, 2019
@MMasey
Copy link
Author

MMasey commented Jun 21, 2019

Manage to solve the issue, once again it was user error and some false positives on my end. 😝

That said i did have to implement this solution to get the scroll positioning saved on the popState - #48 (comment)

@MMasey MMasey closed this as completed Jun 21, 2019
@aerni
Copy link

aerni commented Jul 15, 2019

@MMasey How did you solve this exactly? I'm still having an issue, where the scroll position is set to the saved value upon click on back/forward button, but then scrolling all the way to the top when the animation is done. #48

@tahola
Copy link

tahola commented Jul 23, 2019

Same here, back button click result in bad scrolling position (if I am on the bottom of the page when I click the scroll position of the previous page will be the bottom too), anyway to fix that ?

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

No branches or pull requests

3 participants