gajus / brim

View (minimal-ui) manager for iOS 8.
http://gajus.com/sandbox/brim/demo/
Other
391 stars 41 forks source link

Better scroll prevention #11

Open LorenzoBoccaccia opened 9 years ago

LorenzoBoccaccia commented 9 years ago

When a vertical scroll event is detected, the handler will check where the event happened

If the event it happened on a scrollable element, having scroll or auto css and enough content to be actually scrollable, then the event is allowed to pass

If no scrollable element is under the drag start position, then the event would scroll the page so the event is prevented from propagate

This should properly address issue #3

gajus commented 9 years ago

There are a few problems with this pull request:

  1. var hoisting
  2. Use of document.querySelectorAll('body *') on every touch event is very inefficient.
  3. This code does not pass ESLint.
LorenzoBoccaccia commented 9 years ago

Sorry I'm unfamiliar with js, had to hack together a fix and thought to share it.

Will fix 1 and 3. Any suggestion for 2? One can't just get the div under the cursor as the scrollable one may be the parent. Maybe I can traverse the hierarchy in reverse order but would that work with unrelated position fixed elements overlapping? I don't think.