Skip to content

Commit bb076e3

Browse files
committed
Simulate: account for document scroll in findCenter function. Fixes #6859 - Jquery.Simulate drag behaves incorrect when container scrolled
(cherry picked from commit de3fc00)
1 parent ed65ce7 commit bb076e3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/jquery.simulate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ $.extend($.simulate.prototype, {
123123
this.simulateEvent(target, "click", coord);
124124
},
125125
findCenter: function(el) {
126-
var el = $(this.target), o = el.offset();
126+
var el = $(this.target), o = el.offset(), d = $(document);
127127
return {
128-
x: o.left + el.outerWidth() / 2,
129-
y: o.top + el.outerHeight() / 2
128+
x: o.left + el.outerWidth() / 2 - d.scrollLeft(),
129+
y: o.top + el.outerHeight() / 2 - d.scrollTop()
130130
};
131131
}
132132
});

0 commit comments

Comments
 (0)