question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scroll Behaviour type support in 'app/router.scrollBehavior.ts'

See original GitHub issue

right now doing this

`import { Route } from “vue-router”;

const scrollBehavior = (to: Route, from: Route, savedPosition: any) => { console.log(savedPosition); console.log(to); console.log(from); return { x: 0, y: 0 }; }; export default scrollBehavior;`

has no affect. (console.log shows nothing) whereas changing it to .js works fine. im trying to push to a page (kept alive) with the last saved position.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
kevinmarreccommented, Sep 24, 2020

@e-lobo Yeah so I was right, there’s no currently workaround for now, I’m myself using a .js version in my Nuxt TypeScript projects. I will reach Nuxt Core Team to see if we can enable TypeScript support for this file for Nuxt 3.

0reactions
gigamarrcommented, Aug 15, 2022

Extended @aletz13’s version for nuxt 2.15.8

import { RouterOptions } from 'vue-router'

const scrollBehavior: RouterOptions['scrollBehavior'] = (to, from, savedPosition) => {
    // ...
}

export default scrollBehavior
Read more comments on GitHub >

github_iconTop Results From Across the Web

Scroll Behavior | Vue Router
The scrollBehavior function receives the to and from route objects, like Navigation Guards.
Read more >
Scroll behaviour VueJS not working properly - Stack Overflow
scrollBehavior happens at the same time. The anchor is not found, so no scrolling; Transition is over, <router-view> correctly mounted/rendered.
Read more >
scroll-behavior - CSS: Cascading Style Sheets - MDN Web Docs
The scroll-behavior CSS property sets the behavior for a scrolling box when scrolling is triggered by the navigation or CSSOM scrolling APIs.
Read more >
Handling scrolling on Angular router transitions - Medium
Perfectly handling scroll position upon Angular route transitions. ... register a route path and define the expected scroll behavior for ...
Read more >
Changing Scroll Behavior with Vue Router | by John Au-Yeung
Vue Router lets us adjust the scrolling behavior the way we like when route loads. This only works if the browser supports history....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found