Automattic / antiscroll

OS X Lion style cross-browser native scrolling on the web that gets out of the way.
1.07k stars 162 forks source link

Mousewheel Support is Miscalculated #30

Closed Radagaisus closed 12 years ago

Radagaisus commented 12 years ago

Hey,

On Mac OS X with Chrome there's a rounding error when trying to stop the window from scrolling when reaching the end of the antiscroll box.

> log y, this.innerEl.scrollTop, this.pane.el.height(), this.innerEl.scrollHeight
-0.025 585 299.77777767181396 885 

The mousewheel end detection is this:

if ((y > 0 && 0 == this.innerEl.scrollTop) ||
        (y < 0 && (this.innerEl.scrollTop + this.pane.el.height()
          == this.innerEl.scrollHeight))) {
      ev.preventDefault();
      return false;
    }

A simple fix for the rounding error:

((y > 0 && 0 == this.innerEl.scrollTop) ||
        (y < 0 && (1+this.innerEl.scrollTop + this.pane.el.height()
          >= this.innerEl.scrollHeight)))

or:

((y > 0 && 0 == this.innerEl.scrollTop) ||
        (y < 0 && (this.innerEl.scrollTop + Math.round(this.pane.el.height())
          >= this.innerEl.scrollHeight)))

This applies to both horizontal and vertical scroll.

rauchg commented 12 years ago

Pull request?