From 86724c31f6b4b471c76faa411a0b1799c5f7a228 Mon Sep 17 00:00:00 2001 From: schneefux Date: Thu, 24 May 2018 13:55:22 +0200 Subject: scroll to top after page transition --- static/js/custom.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'static/js/custom.js') diff --git a/static/js/custom.js b/static/js/custom.js index 9f68787..27e5c12 100644 --- a/static/js/custom.js +++ b/static/js/custom.js @@ -1,2 +1,21 @@ +if ('scrollRestoration' in history) { + history.scrollRestoration = 'manual'; +} + +var HideShowTransition = Barba.BaseTransition.extend({ + start: function() { + this.newContainerLoading.then(this.finish.bind(this)); + }, + + finish: function() { + window.scrollTo(0, 0); + this.done(); + } +}); + +Barba.Pjax.getTransition = function() { + return HideShowTransition; +}; + Barba.Pjax.start(); Barba.Prefetch.init(); -- cgit v1.3.1