Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce draw time by removing redundant moveEnd event #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions public/libs/earth/1.0.0/earth.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
var signalEnd = _.debounce(function() {
if (!op || op.type !== "drag" && op.type !== "zoom") {
configuration.save({orientation: globe.orientation()}, {source: "moveEnd"});
dispatch.trigger("moveEnd");
}
}, MOVE_END_WAIT); // wait for a bit to decide if user has stopped moving the globe

Expand Down Expand Up @@ -323,13 +322,15 @@
}

// Throttled draw method helps with slow devices that would get overwhelmed by too many redraw events.
// Trailing call is disabled because, when MOVE_END_WAIT is set to 0, the "redraw" event on rendererAgent
// triggered in doDraw() after 5ms can cause cancelInterpolation() to be called _after_ the "moveEnd" event,
// but before the interpolateField task is run.
var REDRAW_WAIT = 5; // milliseconds
var doDraw_throttled = _.throttle(doDraw, REDRAW_WAIT, {leading: false});
var doDraw_throttled = _.throttle(doDraw, REDRAW_WAIT, {leading: false, trailing: false});

function doDraw() {
d3.selectAll("path").attr("d", path);
rendererAgent.trigger("redraw");
doDraw_throttled = _.throttle(doDraw, REDRAW_WAIT, {leading: false});
}

// Attach to map rendering events on input controller.
Expand Down