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

Navigation between long pages issue #201

Closed
this-user-name opened this issue Sep 24, 2019 · 8 comments
Closed

Navigation between long pages issue #201

this-user-name opened this issue Sep 24, 2019 · 8 comments

Comments

@this-user-name
Copy link

When navigating between pages within the same layout (Or not) there is a behavior that is not very much user friendly in my view.

For example if is there a route-link in the middle/bottom of the page upon click the page goes to top very fast and then is showed the new page. Its kind of annoying :/

Is there any way to fix this ?

Example:
image

@bmpf
Copy link

bmpf commented Sep 27, 2019

There is a quick fix:

Remove return { x: 0, y: 0 } and replace it with a Promise Async Scrolling , set it to 190 (+-)
Read more @ https://router.vuejs.org/guide/advanced/scroll-behavior.html

File : https://github.com/cretueusebiu/laravel-vue-spa/blob/master/resources/js/router/index.js

function scrollBehavior (to, from, savedPosition) {
  if (savedPosition) {
    return savedPosition
  }

  if (to.hash) {
    return { selector: to.hash }
  }

  const [component] = router.getMatchedComponents({ ...to }).slice(-1)

  if (component && component.scrollToTop === false) {
    return {}
  }

  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve({ x: 0, y: 0 })
    }, 190)
  })

  //return { x: 0, y: 0 }
}

@this-user-name
Copy link
Author

It worked . thanks

@jimohalloran
Copy link
Contributor

Seems like a pretty low risk change to make everywhere. @cretueusebiu would you like a PR to add this into this project?

@cretueusebiu
Copy link
Owner

Yeah sure, but what default value should we use ? 100 / 150 / 200 ?

@bmpf
Copy link

bmpf commented Oct 7, 2019

I have found the sweet spot to be 190 ms, I use the same ms in multiple apps , but , just to be safe , you can set it to 200 , You cant notice any difference whatsoever.
You can also play around with css transitions in other to make the value lower. In my view there is no point , the user ll never notice any diference, and a little feedback ( clean and soft page transition) is always nice.

@jimohalloran
Copy link
Contributor

Cool, I had thought a nice CSS scroll back to the top instead of a snap might be nice. I'll try a few different things starting at 190/200 and see what seems to look best.

@cretueusebiu
Copy link
Owner

@jimohalloran Sounds great!

I've seen your other PRs and will hopefully review and merge them very soon.

@jimohalloran
Copy link
Contributor

No rush, whenever you get time. I've got a bit of spare time at the moment, so just giving a little back to a project that's given me a lot over the last year. If there's anything you specifically want me to take a look at, sing out. Happy to help where I can.

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

4 participants