Skip to content

Not All Scroll Events are Heard by $document #67

Open
@HandyAndyShortStack

Description

@HandyAndyShortStack

I was having an issue yesterday when using this library for sorting a group of lists inside a scrollable div. If I began to drag a list item and scrolled the div during the drag, I found that the placeholder would no longer follow my mouse position correctly. It seemed to be tracking a point directly above or below my pointer by the same distance that I had scrolled. Here is an example of what I experienced: http://bl.ocks.org/handyandyshortstack/raw/9005218/.

Upon further investigation, I found this was because the ContainerGroup was not recalculating container and offset metrics in response to these scroll events. It seems that scroll events inside scrollable elements never reach the document, so ContainerGroup.prototype.scroll is not called when they are fired.

I patched up my copy of jquery-sortable by placing the following line at the end of ContainerGroup.prototype.toggleListeners (my copy is based on v0.9.11):

$('#my-scrollable-element')[method]('scroll', that.scrollProxy)

I am already passing in a namespaced jQuery object at the end of the file so one more minor modification is no big deal, but I really think this issue should be dealt with more properly. I am not sure how best to go about it though. Perhaps an additional group default could be exposed where users could pass in additional elements or selectors on which to attach event listeners while dragging. It also might be feasable to look explicitly for css indicating scrollability recursively on the parents of sortable elements and attach listeners to those if they are found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions