Skip to content

Commit

Permalink
Upgrade to Standard 9
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Mar 4, 2017
1 parent fe84b26 commit 127a76d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"postcss-loader": "^1.3.3",
"pre-commit": "^1.2.2",
"rimraf": "^2.6.1",
"standard": "^9.0.0",
"style-loader": "^0.13.2",
}
}
10 changes: 5 additions & 5 deletions src/medium-zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,20 @@ const mediumZoom = (selector, {
const windowWidth = document.body.clientWidth || window.innerWidth
const windowHeight = document.body.clientHeight || window.innerHeight

const viewportWidth = windowWidth - options.margin * 2
const viewportHeight = windowHeight - options.margin * 2
const viewportWidth = windowWidth - (options.margin * 2)
const viewportHeight = windowHeight - (options.margin * 2)

const { width, height, naturalWidth = +Infinity, naturalHeight = +Infinity } = target
const { top, left } = target.getBoundingClientRect()
const isCenterAligned = Math.abs(windowWidth / 2 - (left + width / 2)) <= 10
const isCenterAligned = Math.abs((windowWidth / 2) - (left + (width / 2))) <= 10

const scaleX = Math.min(naturalWidth, viewportWidth) / width
const scaleY = Math.min(naturalHeight, viewportHeight) / height
const scale = Math.min(scaleX, scaleY) || 1
const translateX = isCenterAligned
? 0
: (-left + (viewportWidth - width) / 2) / scale
const translateY = (-top + (viewportHeight - height) / 2 + options.margin) / scale
: (-left + ((viewportWidth - width) / 2)) / scale
const translateY = (-top + ((viewportHeight - height) / 2) + options.margin) / scale

target.style.transform = `scale(${scale}) translate3d(${translateX}px, ${translateY}px, 0)`
}
Expand Down

0 comments on commit 127a76d

Please sign in to comment.