Skip to content

Commit

Permalink
keep progress bar from showing animated stripes when nothing's loadin…
Browse files Browse the repository at this point in the history
…g; addresses my comment in #38
  • Loading branch information
tmaybe committed Apr 7, 2014
1 parent cc98cd7 commit b979c99
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions map/js/PetaCaleg.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,21 +429,10 @@
},

showProgress: function(req) {
if (this._progressReq) {
this._progressReq.on("progress", null);
this._progressReq = null;
}

var container = this.breadcrumb
.classed("loading", true),
loader = container.select(".progress");

if (!req || req.empty()) {
container.classed("loading", false);
loader.classed("done", true);
return req;
}

if (loader.empty()) {
loader = container.insert("div", "*")
.attr("class", "progress done");
Expand All @@ -464,6 +453,20 @@
rest = loader.select(".progress-bar.rest")
.style("width", "100%");

if (this._progressReq) {
container.classed("loading", false);
this._progressReq.on("progress", null);
this._progressReq = null;
}

if (!req || req.empty()) {
container.classed("loading", false);
bar.style("width", "100%");
rest.style("width", "0%");
loader.classed("done", true);
return req;
}

req.on("progress", function(e) {
var done = e.progress >= 1,
pct = Math.floor(e.progress * 100);
Expand Down

0 comments on commit b979c99

Please sign in to comment.