Use mutationObserver to track changes in the page #44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Using mutationObserver (https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) to change from an active tracking system (checking at every tick every divs and loading all of their properties) system to an event based system (keeping the divs and properties in memory and updating them only when they change) to observe changes in the page.
Having all the divs and their properties could also be usefull for easy export and potentially for building a live broadcasted version of cascade
changed title from Use mutationObserver to track changes in the page{- /label idea-} to Use mutationObserver to track changes in the page
marked this issue as related to #35
Branch mutationObserver
Structure:
All cascade elements are kept into the els array. This is the cascade “database”.
A cascade element is composed of
When the page is loaded, all cascade htmlNode are turned into cascade elements. A mutation observer, listening for style changes is placed on them, as well as an other mutation observer listening for changes in childlist (if a new node is added or removed to them). The same mutation observer, listening for childlist changes, is also added to the body.
On every tick, all the cascade elements are interpreted. When a change is made to the DOM, the mutation observer callbacks are triggered and the corresponding cascade element is updated in the els array.
Added computedProperties, an array containing all computed properties like the ratio or the surface, to the structure of the cascade element in commit
a2a8e34cAfter some tests, this seems to be a good change. The code also make more sense. Will confirm it with more use and tests. Thanks for the work.