Closed andreasplesch closed 1 year ago
I would add these lines to appendInlineChildElement
:
switch (node .checkLoadState ())
{
case X3DConstants .COMPLETE_STATE:
{
const event = new CustomEvent ("load",
{
detail: { node: node ? node .valueOf () : null },
});
element .dispatchEvent (event);
break;
}
case X3DConstants .FAILED_STATE:
{
const event = new CustomEvent ("error",
{
detail: { node: node ? node .valueOf () : null },
});
element .dispatchEvent (event);
break;
}
}
Would use load
and error
to be similar to \<image>. This should not collide with the load
field, because one would use onload
attribute with code.
Added documentation:
https://create3000.github.io/x_ite/dom-integration#events-of-inline-element
super.
The 'load' event may be dispatched too early. I think it should be dispatched only after an Inline is completely loaded, eg. after all internal resources, including all internal inlines, are loaded.
has two inlines, which have inlines themselves.
After both inlines have fired 'load', a function tries to access DOM elements from the innermost inlines but fails because the DOM elements are not available.
I can put together a simpler example as well.
Good idea, makes life much more easier. Ready to be tested.
Looks good !
This is a feature users regularly ask for since web programmers are used to such load events from the DOM. This really applies to Inlines due to async loading.
https://github.com/andreasplesch/x_ite_dom/blob/master/src/x_ite_dom.js#L355 dispatched an x3dload event.
The standard solution would be to add a LoadSensor to the scene but I think web programmers would expect this event to be available by default for any scene, even without a LoadSensor. An option would be to add back the embedded LoadSensor but perhaps there are other internal options ?