summaryrefslogtreecommitdiff
path: root/static/js/custom.js
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2018-05-24 13:55:22 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2018-05-24 13:55:22 +0200
commit86724c31f6b4b471c76faa411a0b1799c5f7a228 (patch)
treeaa811e3e63813eb0b991aa541a21f4ba02bd8af3 /static/js/custom.js
parent326ae83c96e9a883f38904c3eec73c1529a6267e (diff)
downloadblog-86724c31f6b4b471c76faa411a0b1799c5f7a228.tar.gz
blog-86724c31f6b4b471c76faa411a0b1799c5f7a228.zip
scroll to top after page transition
Diffstat (limited to 'static/js/custom.js')
-rw-r--r--static/js/custom.js19
1 files changed, 19 insertions, 0 deletions
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();