add smooth behavior on scrollBehavior savedPosition in VueRouter

Viewed 75

Im adding the scrollBehavior in vueRouter and I can't find anywhere how can I add the behavior: smooth on the savedPosition in a timeout? here is my code where I would like to add the smooth option :

  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return new Promise((resolve) => {
        setTimeout(() => {
          resolve(savedPosition);
        }, 1000);
      });
    }
  },

Thank you alot in advance.

1 Answers

Try this

    scrollBehavior(to, from, savedPosition) {
      if (savedPosition) {
        return new Promise((resolve) => {
          setTimeout(() => {
            savedPosition.behavior = "smooth"
            resolve(savedPosition);
        }, 1000);
      });
    }
  },
Related