From 48e6d56ec112ff59c0e2ab14e605e7ef02350256 Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Wed, 2 Oct 2019 17:55:00 +0000 Subject: [PATCH] always scroll to top on page change --- app/frontpage/frontpage.js | 2 -- app/index.js | 12 ++++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/frontpage/frontpage.js b/app/frontpage/frontpage.js index 585529b..0081bf4 100644 --- a/app/frontpage/frontpage.js +++ b/app/frontpage/frontpage.js @@ -83,9 +83,7 @@ const Frontpage = { }, view: function(vnode) { - console.log(this.articles) var deviceWidth = window.innerWidth - var bannerPath = '' if (this.featured && this.featured.banner) { diff --git a/app/index.js b/app/index.js index de49630..07a4d4f 100644 --- a/app/index.js +++ b/app/index.js @@ -1,6 +1,18 @@ const m = require('mithril') window.m = m +m.route.setOrig = m.route.set +m.route.set = function(path, data, options){ + m.route.setOrig(path, data, options) + window.scrollTo(0, 0) +} + +m.route.linkOrig = m.route.link +m.route.link = function(vnode){ + m.route.linkOrig(vnode) + window.scrollTo(0, 0) +} + const Authentication = require('./authentication') m.route.prefix = ''