aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/scrollSnap.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2016-12-21 11:55:02 +0100
committerNoah Loomans <noahloomans@gmail.com>2016-12-21 11:55:02 +0100
commit7ec11ecfc447c66582e16d4e832cbfc089139e29 (patch)
tree90475f185803ab8bbc789102880c906932e520eb /public/javascripts/scrollSnap.js
parent0f50fb9ddc50b35faa8b927b9dbf81d006ba0094 (diff)
fixed ie
Diffstat (limited to 'public/javascripts/scrollSnap.js')
-rw-r--r--public/javascripts/scrollSnap.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/public/javascripts/scrollSnap.js b/public/javascripts/scrollSnap.js
index 4f71f28..ed7bbb3 100644
--- a/public/javascripts/scrollSnap.js
+++ b/public/javascripts/scrollSnap.js
@@ -10,8 +10,14 @@ self._nodes = {
self._timeoutID = null
+self._getScrollPosition = function () {
+ return (document.documentElement && document.documentElement.scrollTop) ||
+ document.body.scrollTop
+}
+
self._handleDoneScrolling = function () {
- const scrollPosition = document.body.scrollTop
+ console.log('done scrolling')
+ const scrollPosition = self._getScrollPosition()
const weekSelectorHeight = self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight
if (scrollPosition < weekSelectorHeight && scrollPosition > 0) {
window.scroll({ top: weekSelectorHeight, left: 0, behavior: 'smooth' })
@@ -22,8 +28,9 @@ self._handleScroll = function () {
if (self._timeoutID != null) window.clearTimeout(self._timeoutID)
self._timeoutID = window.setTimeout(self._handleDoneScrolling, 500)
- const scrollPosition = document.body.scrollTop
+ const scrollPosition = self._getScrollPosition()
const weekSelectorHeight = self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight
+ console.log(scrollPosition, weekSelectorHeight)
if (scrollPosition >= weekSelectorHeight) {
document.body.classList.add('week-selector-not-visible')
} else {
@@ -35,7 +42,7 @@ self._handleWindowResize = function () {
const weekSelectorHeight = self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight
const extraPixelsNeeded = weekSelectorHeight - (document.body.clientHeight - window.innerHeight)
if (extraPixelsNeeded > 0) {
- document.body.style.marginBottom = `${extraPixelsNeeded}px`
+ document.body.style.marginBottom = extraPixelsNeeded + 'px'
} else {
document.body.style.marginBottom = null
}