kornelski / slip

Slip.js — UI library for manipulating lists via swipe and drag gestures
BSD 2-Clause "Simplified" License
2.44k stars 213 forks source link

Fix scrolling, to use document.scrollingElement instead of document.body #110

Closed carter-thaxton closed 5 years ago

carter-thaxton commented 5 years ago

This fixes #109

I refactored the logic around this some time ago, but left the choice to default to document.body. Scrolling with document.body is no longer working in the latest versions of webkit, and we probably should have been defaulting to use document.scrollingElement all along.

IE doesn't have document.scrollingElement, but documentElement seems to work just fine.

While setting overflow-y on one of the parent nodes will still work with this (see example.html for some nested lists), I've noticed that recent versions of webkit have some strange behavior that doesn't let the scroll go all the way, when scrolling within an element, and not the entire page. I was running into that in my app, and this fix along with some changes to the overflow-y property in my app CSS fixed the issue.

This PR also allows scrollContainer to be explicitly set as an option, in case anyone wants even finer control of which parent is getting its scrollTop set during the reorder dragging.