Skip to content

Commit

Permalink
don't use setTimeout on drag for browsers without requestAnimFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jun 17, 2011
1 parent d2487e8 commit d3f0ba5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions dist/leaflet.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/core/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ L.Util = {
window.msRequestAnimationFrame ||
timeoutDefer;

return function(callback, context) {
return function(callback, context, immediate) {
callback = context ? L.Util.bind(callback, context) : context;
requestFn(callback);
if (immediate && requestFn === timeoutDefer) {
callback();
} else {
requestFn(callback);
}
};
})(),

Expand Down
2 changes: 1 addition & 1 deletion src/dom/Draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ L.Draggable = L.Class.extend({
var newPoint = new L.Point(first.clientX, first.clientY);
this._newPos = this._startPos.add(newPoint).subtract(this._startPoint);

L.Util.requestAnimFrame(this._updatePosition, this);
L.Util.requestAnimFrame(this._updatePosition, this, true);

this.fire('drag');
},
Expand Down

0 comments on commit d3f0ba5

Please sign in to comment.