Skip to content

Commit

Permalink
Mozilla FF document.body.scrollTop patch
Browse files Browse the repository at this point in the history
  • Loading branch information
junk committed Jul 18, 2017
1 parent c29c956 commit ee13718
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/medium-zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const mediumZoom = (selector, {
const event = new Event('show')
target.dispatchEvent(event)

scrollTop = document.body.scrollTop
scrollTop = (document.documentElement.scrollTop || document.body.scrollTop) //fix for Mozilla, cause document.body.scrollTop property always equal 0
isAnimating = true

document.body.appendChild(overlay)
Expand Down Expand Up @@ -185,7 +185,9 @@ const mediumZoom = (selector, {
const onScroll = () => {
if (isAnimating || !target) return

if (Math.abs(scrollTop - document.body.scrollTop) > options.scrollOffset) {
let currentScroll = (document.documentElement.scrollTop || document.body.scrollTop); //mozilla fix

if (Math.abs(scrollTop - currentScroll) > options.scrollOffset) {
zoomOut()
}
}
Expand Down

0 comments on commit ee13718

Please sign in to comment.