Skip to content

Commit b825d8e

Browse files
committed
restore smooth scrolling by fixing mouseevent-filtered
1 parent aba23fc commit b825d8e

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

select2.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,19 @@
154154
});
155155
}
156156

157+
$(document).delegate("*", "mousemove", function (e) {
158+
$(document).data("select2-lastpos", {x: e.pageX, y: e.pageY});
159+
});
160+
157161
/**
158162
* filters mouse events so an event is fired only if the mouse moved.
159163
*
160164
* filters out mouse events that occur when mouse is stationary but
161165
* the elements under the pointer are scrolled.
162166
*/
163167
function installFilteredMouseMove(element) {
164-
var context = $(element[0].document);
165-
context.on("mousemove", function (e) {
166-
context.data("select2-lastpos", {x: e.pageX, y: e.pageY});
167-
});
168-
element.bind("mousemove", function (e) {
169-
var lastpos = context.data("select2-lastpos");
168+
element.bind("mousemove", function (e) {
169+
var lastpos = $(document).data("select2-lastpos");
170170
if (lastpos === undefined || lastpos.x !== e.pageX || lastpos.y !== e.pageY) {
171171
$(e.target).trigger("mousemove-filtered", e);
172172
}
@@ -422,8 +422,8 @@
422422
// initialize the container
423423
this.initContainer();
424424

425-
//installFilteredMouseMove(this.results);
426-
this.dropdown.delegate(resultsSelector, "mouseover", this.bind(this.highlightUnderEvent));
425+
installFilteredMouseMove(this.results);
426+
this.dropdown.delegate(resultsSelector, "mousemove-filtered", this.bind(this.highlightUnderEvent));
427427

428428
installDebouncedScroll(80, this.results);
429429
this.dropdown.delegate(resultsSelector, "scroll-debounced", this.bind(this.loadMoreIfNeeded));

0 commit comments

Comments
 (0)