From faf291b63ece87b167b0983cf6c43598b78fed07 Mon Sep 17 00:00:00 2001 From: kaesonho Date: Wed, 21 Oct 2015 02:53:01 -0700 Subject: [PATCH] set history.scrollRestoration as manual if scroll enabled --- lib/handleHistory.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/handleHistory.js b/lib/handleHistory.js index 7ead98b..b9dd1e3 100644 --- a/lib/handleHistory.js +++ b/lib/handleHistory.js @@ -76,6 +76,13 @@ function createComponent(Component, opts) { }); } } + + if (options.enableScroll && window.history) { + // https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration?hl=en + // disable browser auto scroll behavior with popstate + window.history.scrollRestoration = 'manual'; + } + this._history.on(this._onHistoryChange); window.addEventListener('scroll', this._onScroll);