Element added to visible DOM event -


is there dom event when element added visible dom?

to describe better:

i have div element created, not yet added document. i'm adding child it. @ moment need calculations based on child rect - if take rect @ moment getclientboundingrect - "zero" element not yet displayed.

the problem don't know when parent div added document can't apply logic after.

let p = document.createelement("div"); let c = document.createelement("div"); c.textcontent = "boo!"; c.addeventlistener("some cool event", () => { alert("boo!")});  p.appendchild(c);  document.body.appendchild(p);  // "some cool event" trigger @ moment 

was thinking mutationobserver - not sure applies here. thanks!


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -