Wait globe to load world.jpg before display it

This commit is contained in:
HelloZeroNet 2016-03-18 19:20:49 +01:00
parent 5af32f21fd
commit a3bba8c14c
2 changed files with 47 additions and 39 deletions

View file

@ -351,6 +351,9 @@ class Sidebar extends Class
displayGlobe: => displayGlobe: =>
img = new Image();
img.src = "/uimedia/globe/world.jpg";
img.onload = =>
wrapper.ws.cmd "sidebarGetPeers", [], (globe_data) => wrapper.ws.cmd "sidebarGetPeers", [], (globe_data) =>
if @globe if @globe
@globe.scene.remove(@globe.points) @globe.scene.remove(@globe.points)

View file

@ -601,8 +601,12 @@ window.initScrollable = function () {
}; };
Sidebar.prototype.displayGlobe = function() { Sidebar.prototype.displayGlobe = function() {
return wrapper.ws.cmd("sidebarGetPeers", [], (function(_this) { var img;
return function(globe_data) { img = new Image();
img.src = "/uimedia/globe/world.jpg";
return img.onload = (function(_this) {
return function() {
return wrapper.ws.cmd("sidebarGetPeers", [], function(globe_data) {
var e; var e;
if (_this.globe) { if (_this.globe) {
_this.globe.scene.remove(_this.globe.points); _this.globe.scene.remove(_this.globe.points);
@ -630,8 +634,9 @@ window.initScrollable = function () {
} }
} }
return _this.tag.find(".globe").removeClass("loading"); return _this.tag.find(".globe").removeClass("loading");
});
}; };
})(this)); })(this);
}; };
Sidebar.prototype.unloadGlobe = function() { Sidebar.prototype.unloadGlobe = function() {