fix: slider position error when zoom is not 1 #227

pull/263/head
tangjinzhou 2018-10-24 15:55:40 +08:00
parent 46b71b2e0a
commit 90d33b019b
1 changed files with 10 additions and 2 deletions

View File

@ -35,11 +35,19 @@ export function getPrecision (step) {
} }
export function getMousePosition (vertical, e) { export function getMousePosition (vertical, e) {
return vertical ? e.clientY : e.pageX let zoom = 1
if (window.visualViewport) {
zoom = +(window.visualViewport.width / document.body.getBoundingClientRect().width).toFixed(2)
}
return (vertical ? e.clientY : e.pageX) / zoom
} }
export function getTouchPosition (vertical, e) { export function getTouchPosition (vertical, e) {
return vertical ? e.touches[0].clientY : e.touches[0].pageX let zoom = 1
if (window.visualViewport) {
zoom = +(window.visualViewport.width / document.body.getBoundingClientRect().width).toFixed(2)
}
return (vertical ? e.touches[0].clientY : e.touches[0].pageX) / zoom
} }
export function getHandleCenterPosition (vertical, handle) { export function getHandleCenterPosition (vertical, handle) {