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

Page height grows when dragging item beyond page bottom #29

Closed guillerodriguez closed 8 years ago

guillerodriguez commented 10 years ago

When testing on desktop browsers (Chrome, FF) I found that trying to drag an item beyond the bottom of the page quickly makes the page height grow out of control (the page height will keep growing as long as you keep dragging the item beyond the page bottom). This can be seen in the live demo at http://pornel.net/slip

The following fix in updatePosition() avoids this problem:

        if (bottomOffset < triggerOffset){
            offset = triggerOffset - bottomOffset;

            // Don't apply offset if it would scroll beyond the end of the page
            var rootEl = document.documentElement,
                bodyEl = document.body,
                scrollTop = (rootEl && rootEl.scrollTop) || bodyEl.scrollTop,
                scrollHeight = (rootEl && rootEl.scrollHeight) || bodyEl.scrollHeight;

            if ((scrollTop + window.innerHeight + offset) >= scrollHeight) {
                offset = 0;
            }
        }
        else if (topOffset < triggerOffset){
            offset = topOffset - triggerOffset;
        }
henrikhermansen commented 9 years ago

@guillerodriguez this disables scrolling while holding an item, if your list is higher than the screen size. Thus this is rather undesirable for mobile.

carter-thaxton commented 8 years ago

I believe these issues were fixed in #71 and #72. Please feel free to reopen if you find additional issues.