nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

scrollBehavior Glitches

Open pi0 opened this issue 9 years ago • 58 comments

Hi. We have various issues reported for scrollBehavior not behaving as desired. Maybe use-cases differ but almost all of them are related to the same known issue and we are aware and plan to help fixing it. Please don't make/reopen duplicated issues as there is enough info about the problem.It just makes the process harder. As of always contributions and PRs are appreciated to both vue-router and nuxt for possible fixes.

vue-router

  • Handle scrollBehaviour with transitions (vuejs/vue-router#1263)
  • Another detail of scrollBehavior wrapped in transition(vuejs/vue-router#1373)
  • scrollBehavior doesn't work for initial route in Firefox (vuejs/vue-router#1585)
  • Need a way to set what scroll position is saved (vuejs/vue-router#1187)
  • Navigating back should retain the scroll position. (vuejs/vue-router#1669)
  • Support parent container for scroll behavior (vuejs/vue-router#1249)
  • Calcurated scroll position is incorrect in some browser with animation (vuejs/vue-router#1530)

Issues

  • Strange behavior in Firefox browser when page transition (#1373)
  • What causes a glitch when page transition in Firefox? (#1002)
  • Delayed scroll top possible? (#1355)
  • ScrollBehavior: Fires too early (#1036)
  • Navigating back should retain the scroll position. (#1182)

Reproductions

  • https://github.com/krestaino/scroll-position-nuxt (@krestaino, #1182)
  • http://jsfiddle.net/qw4hbgek (@posva, vuejs/vue-router#1263)
  • http://jsfiddle.net/xctnu8r3/2 (@nickforddesign , vuejs/vue-router#1373)
  • https://github.com/vuejs/vue-router/tree/dev/examples/scroll-behavior (@hworld, vuejs/vue-router#1585)
  • http://codepen.io/brad426/pen/pezRge (@brad426)

Misc

  • https://nuxtjs.org/faq/css-flash
This bug report is available on Nuxt.js community (#c1219)

pi0 avatar Aug 14 '17 19:08 pi0

UPDATE new Async Scrolling will be available with [email protected] (Thanks to @homerjam . vuejs/vue-router#1758)

pi0 avatar Oct 12 '17 15:10 pi0

Excellent, does anyone have a good way to hook this up with the router transition object to detect when to scroll? Or should we be using a timeout like in the documentation's example.

typewriter-software avatar Oct 12 '17 15:10 typewriter-software

@pi0 is there's a hope that it will fix ScrollToTop page transitions?

hackuun avatar Oct 12 '17 16:10 hackuun

@typewriter-software check out updated example here https://github.com/vuejs/vue-router/pull/1804 we still need a small modification to vue-router for this to work (I wish I had included this in my last PR!).

homerjam avatar Oct 13 '17 19:10 homerjam

#1376

atinux avatar Nov 02 '17 11:11 atinux

Any changes? How to use this promise?

hackuun avatar Nov 07 '17 14:11 hackuun

@iamdubx still waiting for the PR referenced above to be released, then I can make an example. For now you should be able to get it to work by installing vue-router from github and using the afterLeave hook as in the example in the PR (the afterLeave hook goes in nuxt.config.js).

homerjam avatar Nov 07 '17 15:11 homerjam

@homerjam good to hear, that it's not only me concern this issue. Meanwhile, I found this awesome project, and wonder, how it fix Scroll behavior? I can't find anything regarding this issue in source code - https://github.com/krestaino/nuepress Any ideas how it was done?

hackuun avatar Nov 08 '17 16:11 hackuun

It looks to me like it's using the default scroll behaviour but the transitions are so quick you don't see any issues.

homerjam avatar Nov 08 '17 17:11 homerjam

@iamdubx Thanks! I've been eyeing this issue for some time now, once this issue is resolved in Nuxt I'll update NuePress with the fix.

@homerjam I am suffering from this scroll issue actually. It just appears sporadically as far as I've noticed.

krestaino avatar Nov 08 '17 17:11 krestaino

I also can't wait for this fix. Scrollbehavior doesn't work at all for us, even scrollBehavior function is not being called at all. I am using spa config with hash router mode.

husayt avatar Nov 11 '17 23:11 husayt

I don't want to start a new thread so going to pop it in here, does this include an issue of pages not scrolling to the top and just snapping there? I seem to have that issue on nuxt examples and a clean install in all browsers i try.

dan-gamble avatar Jan 11 '18 21:01 dan-gamble

@dan-gamble Is this relevant at all to your issue?

https://nuxtjs.org/api/pages-scrolltotop/

krestaino avatar Jan 11 '18 21:01 krestaino

That seems to break my page weirdly enough, it also still snaps to the top for some reason.

dan-gamble avatar Jan 11 '18 21:01 dan-gamble

Found out i needed:

    watchQuery: ['page'],
    key: (to) => to.fullPath,

To get me working again, scrollToTop still snaps up for me though. I'll get a video to show what i get.

Edit video

dan-gamble avatar Jan 11 '18 22:01 dan-gamble

Is there any status update on all this? Vue, Nuxt, etc are absolutely fantastic, but the bizarre scrolling to top before route transitions makes the ecosystem pretty much unusable for us. Most of our pages are image-intensive, with large images at the top of each page. With that sort of UI, the scrolling to top before every transition is very noticeable (with or without transition animation) and makes for a terrible user experience. I'm happy to start digging into the source code to try to figure out a workaround, but many others have already tried and it sounds like this is already an area of focus for the core contributors so I'd likely be wasting my time. Unfortunately we're at (or well past) the point where my team needs to make a final decision on React vs. Vue, and this is a critical issue so any status update would be greatly appreciated!

jkole avatar Jan 18 '18 21:01 jkole

I made head way with it but paused waiting for a PR on vue-router which has now been merged. I'll try to make an example, but fairly sure it's resolvable with a custom scrollbehavior function and a transition event/hook.

On 18 Jan 2018 21:34, "John Kole" [email protected] wrote:

Is there any status update on all this? Vue, Nuxt, etc are absolutely fantastic, but the bizarre scrolling to top before route transitions makes the ecosystem pretty much unusable for us. Most of our pages are image-intensive, with large images at the top of each page. With that sort of UI, the scrolling to top before every transition is very noticeable (with or without transition animation) and makes for a terrible user experience. I'm happy to start digging into the source code to try to figure out a workaround, but many others have already tried and it sounds like this is already an area of focus for the core contributors so I'd likely be wasting my time. Unfortunately we're at (or well past) the point where my team needs to make a final decision on React vs. Vue, and this is a critical issue so any status update would be greatly appreciated!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nuxt/nuxt.js/issues/1376#issuecomment-358788870, or mute the thread https://github.com/notifications/unsubscribe-auth/ABAcGR31wbbnldHa48WqoW6oPnPNjnwrks5tL7jTgaJpZM4O2xp3 .

homerjam avatar Jan 18 '18 22:01 homerjam

@homerjam an example would be awesome -- I'm just wrapping up my nuxt project and would really like to get this resolved before launch.

mcrider avatar Jan 18 '18 22:01 mcrider

No probs - I also need it for a project I'm working on. If you wouldn't mind clarifying exactly what behaviour you're hoping for that'd be useful, eg when it should scroll/remember position/reset etc.

On 18 Jan 2018 22:05, "Matt Crider" [email protected] wrote:

@homerjam https://github.com/homerjam an example would be awesome -- I'm just wrapping up my nuxt project and would really like to get this resolved before launch.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nuxt/nuxt.js/issues/1376#issuecomment-358797244, or mute the thread https://github.com/notifications/unsubscribe-auth/ABAcGcYVcFvnu14K0WE61YCuPgJSXomlks5tL8A0gaJpZM4O2xp3 .

homerjam avatar Jan 18 '18 22:01 homerjam

@homerjam An example would be incredibly helpful. For my specific use case, the scroll position does not return to where it was when navigating back. You can see a minimal repo example on this issue.

https://github.com/nuxt/nuxt.js/issues/1182

krestaino avatar Jan 18 '18 22:01 krestaino