Cherry picked: Fixed false distance reading

Cherry picked https://github.com/cferdinandi/smooth-scroll/commit/208b5a0dd6a56a7bdf2770e7f309e51dc9cfe525