Fix requirement for Math.sign

This commit is contained in:
squidfunk
2017-01-22 13:55:56 +01:00
committed by Martin Donath
parent f71359ce65
commit b09e334f3f
3 changed files with 6 additions and 6 deletions

View File

@@ -42,7 +42,7 @@ export default class Blur {
this.offset_ = window.pageYOffset
/* Necessary state to correctly reset the index */
this.dir_ = 0
this.dir_ = false
/* Index anchor node offsets for fast lookup */
this.anchors_ = [].map.call(this.els_, el => {
@@ -65,12 +65,12 @@ export default class Blur {
*/
update() {
const offset = window.pageYOffset
const dir = Math.sign(this.offset_ - offset)
const dir = this.offset_ - offset < 0
/* Hack: reset index if direction changed, to catch very fast scrolling,
because otherwise we would have to register a timer and that sucks */
if (this.dir_ !== dir)
this.index_ = dir < 0
this.index_ = dir
? this.index_ = 0
: this.index_ = this.els_.length - 1