Listening for page loaded event instead of set timeout === less lag

This commit is contained in:
ericrius1 2016-02-16 11:42:01 -08:00
parent 46679b29f7
commit 46907f446b

View file

@ -1895,16 +1895,18 @@ entityListTool.webView.eventBridge.webEventReceived.connect(function(data) {
// Now we want to activate the partice explorer panel! // Now we want to activate the partice explorer panel!
particleExplorerTool.createWebView(); particleExplorerTool.createWebView();
var properties = Entities.getEntityProperties(ids[0]); var properties = Entities.getEntityProperties(ids[0]);
var data = { var particleData = {
messageType: "particle_settings", messageType: "particle_settings",
currentProperties: properties currentProperties: properties
}; };
particleExplorerTool.setActiveParticleEntity(ids[0]); particleExplorerTool.setActiveParticleEntity(ids[0]);
Script.setTimeout(function() {
// Wait for event bridge on web side to open
particleExplorerTool.webView.eventBridge.emitScriptEvent(JSON.stringify(data));
}, 2000)
particleExplorerTool.webView.eventBridge.webEventReceived.connect(function(data) {
var data = JSON.parse(data);
if (data.messageType === "page_loaded") {
particleExplorerTool.webView.eventBridge.emitScriptEvent(JSON.stringify(particleData));
}
});
} else { } else {
particleExplorerTool.destroyWebView(); particleExplorerTool.destroyWebView();
} }