Fix initial size js
This commit is contained in:
parent
8ef0a12ab4
commit
980b2880d7
|
@ -105,17 +105,25 @@ function ooui (rootElementPath) {
|
||||||
|
|
||||||
console.log("Web socket created");
|
console.log("Web socket created");
|
||||||
|
|
||||||
// Throttled window resize event
|
monitorSizeChanges (1000/10);
|
||||||
(function() {
|
}
|
||||||
window.addEventListener("resize", resizeThrottler, false);
|
|
||||||
|
|
||||||
|
function oouiWasm (mainAsmName, mainNamspace, mainClassName, mainMethodNmae, assemblies)
|
||||||
|
{
|
||||||
|
Module.assemblies = assemblies;
|
||||||
|
|
||||||
|
monitorSizeChanges (1000/30);
|
||||||
|
}
|
||||||
|
|
||||||
|
function monitorSizeChanges (millis)
|
||||||
|
{
|
||||||
var resizeTimeout;
|
var resizeTimeout;
|
||||||
function resizeThrottler() {
|
function resizeThrottler() {
|
||||||
if (!resizeTimeout) {
|
if (!resizeTimeout) {
|
||||||
resizeTimeout = setTimeout(function() {
|
resizeTimeout = setTimeout(function() {
|
||||||
resizeTimeout = null;
|
resizeTimeout = null;
|
||||||
resizeHandler();
|
resizeHandler();
|
||||||
}, 100);
|
}, millis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,28 +139,8 @@ function ooui (rootElementPath) {
|
||||||
send (ems);
|
send (ems);
|
||||||
if (debug) console.log ("Event", em);
|
if (debug) console.log ("Event", em);
|
||||||
}
|
}
|
||||||
}());
|
|
||||||
}
|
|
||||||
|
|
||||||
function oouiWasm (mainAsmName, mainNamspace, mainClassName, mainMethodNmae, assemblies)
|
window.addEventListener("resize", resizeThrottler, false);
|
||||||
{
|
|
||||||
Module.assemblies = assemblies;
|
|
||||||
|
|
||||||
var initialSize = getSize ();
|
|
||||||
|
|
||||||
function resizeHandler() {
|
|
||||||
const em = {
|
|
||||||
m: "event",
|
|
||||||
id: "window",
|
|
||||||
k: "resize",
|
|
||||||
v: getSize (),
|
|
||||||
};
|
|
||||||
const ems = JSON.stringify (em);
|
|
||||||
send (ems);
|
|
||||||
if (debug) console.log ("Event", em);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener ("resize", resizeHandler, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNode (id) {
|
function getNode (id) {
|
||||||
|
@ -330,11 +318,13 @@ function fixupValue (v) {
|
||||||
window["__oouiReceiveMessages"] = function (sessionId, messages)
|
window["__oouiReceiveMessages"] = function (sessionId, messages)
|
||||||
{
|
{
|
||||||
if (debug) console.log ("WebAssembly Receive", messages);
|
if (debug) console.log ("WebAssembly Receive", messages);
|
||||||
|
if (wasmSession != null) {
|
||||||
messages.forEach (function (m) {
|
messages.forEach (function (m) {
|
||||||
// console.log ('Raw value from server', m.v);
|
// console.log ('Raw value from server', m.v);
|
||||||
m.v = fixupValue (m.v);
|
m.v = fixupValue (m.v);
|
||||||
processMessage (m);
|
processMessage (m);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var Module = {
|
var Module = {
|
||||||
|
@ -433,8 +423,9 @@ var WebAssemblyApp = {
|
||||||
var sessionId = "main";
|
var sessionId = "main";
|
||||||
var rres = MonoRuntime.call_method (this.main_method, null, [MonoRuntime.mono_string (a), MonoRuntime.mono_string (b)]);
|
var rres = MonoRuntime.call_method (this.main_method, null, [MonoRuntime.mono_string (a), MonoRuntime.mono_string (b)]);
|
||||||
var res = MonoRuntime.conv_string (rres);
|
var res = MonoRuntime.conv_string (rres);
|
||||||
MonoRuntime.call_method (this.ooui_StartWebAssemblySession_method, null, [MonoRuntime.mono_string (sessionId), MonoRuntime.mono_string ("main")]);
|
|
||||||
wasmSession = sessionId;
|
wasmSession = sessionId;
|
||||||
|
var initialSize = getSize ();
|
||||||
|
MonoRuntime.call_method (this.ooui_StartWebAssemblySession_method, null, [MonoRuntime.mono_string (sessionId), MonoRuntime.mono_string ("main"), MonoRuntime.mono_string (Math.round(initialSize.width) + " " + Math.round(initialSize.height))]);
|
||||||
return res;
|
return res;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return e.msg;
|
return e.msg;
|
||||||
|
|
Loading…
Reference in New Issue