003d6053a9
This prevents scrolling within scrollable containers (excluding the dropdown) when the dropdown is open. This fixes an issue where the dropdown would go out of sync with the parent container when the parent container was scrolled. We did not have this issue in past versions of Select2 because the mask prevented any scrolling. Now that we have removed the mask, we have to deal with scrolling from different areas of the page. We initially tried to hook into the `scroll` events of the parent containers, but because of a list of issues we decided against it. If the container scrolled out of view, the dropdown would still be left open and above everything else, even though the container wasn't visually connected to it. The `scroll` event does not bubble, so we need to attach the `scroll` handler to every parent element that is scrollable. Since it is surprisingly difficult to determine if an element is scrollable, we modified some CC-BY-SA code and use that to determine if the element has a scrollbar. The original `hasScroll` function can be found at http://codereview.stackexchange.com/q/13338, the same link left within the code, and was originally designed to be a sizzle selector. As Select2 does not require a sizzle-compatible version of jQuery, we converted it into a function that could be used with `.filter` to filter down the elements. This closes https://github.com/select2/select2/issues/2975. |
||
---|---|---|
.. | ||
css | ||
js |