From 50fd48d720ac0d193897556773140bfb6aab0883 Mon Sep 17 00:00:00 2001 From: Dzinlife Date: Sun, 15 Oct 2017 18:42:35 +0800 Subject: [PATCH 1/3] Prevent browser scroll behavior on History popstate --- src/util/scroll.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/scroll.js b/src/util/scroll.js index 9991adaa7..f6fe154da 100644 --- a/src/util/scroll.js +++ b/src/util/scroll.js @@ -7,6 +7,8 @@ import { getStateKey, setStateKey } from './push-state' const positionStore = Object.create(null) export function setupScroll () { + // Prevent browser scroll behavior on History popstate + window.history.scrollRestoration = 'manual'; // Fix for #1585 for Firefox window.history.replaceState({ key: getStateKey() }, '') window.addEventListener('popstate', e => { From ad2052772df9871ae7d28ac2293d0b83cd85d526 Mon Sep 17 00:00:00 2001 From: Joe Wong Date: Sun, 15 Oct 2017 19:05:32 +0800 Subject: [PATCH 2/3] remove semicolon --- src/util/scroll.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/scroll.js b/src/util/scroll.js index f6fe154da..e1ecc033e 100644 --- a/src/util/scroll.js +++ b/src/util/scroll.js @@ -8,7 +8,7 @@ const positionStore = Object.create(null) export function setupScroll () { // Prevent browser scroll behavior on History popstate - window.history.scrollRestoration = 'manual'; + window.history.scrollRestoration = 'manual' // Fix for #1585 for Firefox window.history.replaceState({ key: getStateKey() }, '') window.addEventListener('popstate', e => { From 5d0306f30b31e1c8f40422865ab8d60814981310 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sat, 9 May 2020 11:53:05 +0200 Subject: [PATCH 3/3] Update src/util/scroll.js --- src/util/scroll.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/scroll.js b/src/util/scroll.js index e1ecc033e..d30c08c93 100644 --- a/src/util/scroll.js +++ b/src/util/scroll.js @@ -8,7 +8,9 @@ const positionStore = Object.create(null) export function setupScroll () { // Prevent browser scroll behavior on History popstate - window.history.scrollRestoration = 'manual' + if ('scrollRestoration' in window.history) { + window.history.scrollRestoration = 'manual' + } // Fix for #1585 for Firefox window.history.replaceState({ key: getStateKey() }, '') window.addEventListener('popstate', e => {