Famous / famous-cli

Other
28 stars 20 forks source link

Only works on document load #21

Open michaelobriena opened 9 years ago

michaelobriena commented 9 years ago

One second after the document is loaded, https://assets-beta.famo.us/embed/embed.js doesn't convert the famous-container into the iframe.

Check plunkr (hit run / see console in dev tools)

http://plnkr.co/edit/As2ewoxhQ896ygfzDQ8N?p=preview

So injecting famous-container after ajax requests, or rendering it with a timed ngIf (as in the example) won't work.

Copied from:

https://github.com/Famous/engine/issues/193

michaelobriena commented 9 years ago

If it is not there on page load, we should at least have an API for the embed script to do the embedding.

isaldarriaga commented 9 years ago

I faced the performance issues of mutation events.

they have changed in DOM 4 to mutation observers

https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver (https://www.youtube.com/watch?v=eRZ4pO0gVWw)

isaldarriaga commented 9 years ago

Solved with mutation observer (DOM 4).

Design: observe the document body (children and subtree) and if a valid "famous-container" element node is mutating (added), fire the embed's manage function for them.

http://plnkr.co/edit/O10LY5?p=preview

Tested in chrome 43, FF 38.

Still doesn't work in IE11 because "promise is undefined" (not related to this issue. maybe a new issue for this is required) error in bundle.js 346 of my plunkr.