From c8c8f5eb6d9a454980c46fa6bf07de436005090d Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Wed, 28 Dec 2016 08:11:35 +0200 Subject: [PATCH] #237: fix scrollTo viewport element --- src/components/ui/scrollTo.js | 8 +++++++- src/index.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/ui/scrollTo.js b/src/components/ui/scrollTo.js index 5f6d809..ab84eb7 100644 --- a/src/components/ui/scrollTo.js +++ b/src/components/ui/scrollTo.js @@ -31,7 +31,13 @@ export default function scrollTo(y, viewPort) { return; } - viewPort.scrollTop = y + delta; + const newScrollTop = y + delta; + viewPort.scrollTop = newScrollTop; + + if (viewPort.scrollTop === 0) { + scrollWasTouched = true; + console.warn('The viewPort is not scrollable', viewPort); + } }()); }); diff --git a/src/index.js b/src/index.js index 9b2232e..b5059eb 100644 --- a/src/index.js +++ b/src/index.js @@ -73,7 +73,7 @@ function restoreScroll() { setTimeout(() => { const id = hash.replace('#', ''); const el = id ? document.getElementById(id) : null; - const viewPort = document.getElementById('view-port'); + const viewPort = document.body; if (!viewPort) { console.log('Can not find viewPort element');