bartbutenaers / node-red-dashboard-2-ui-svg

A Node-RED UI node to show SVG drawings in Node-RED dashboard v2
Apache License 2.0
7 stars 2 forks source link

How to update newly injected SVG #4

Open bartbutenaers opened 7 months ago

bartbutenaers commented 7 months ago

When a new SVG string is injected via an input message, it might be useful to clone the delta's of the old SVG to the new one. That way we can update an SVG drawing without loosing state.

For example:

  1. A floorplan svg is injected and displayed.
  2. A message is injected to update the floorplan (e..g let a sensor mdi icon start blinking red).
  3. The floorplan drawing is updated in an external drawing editor.
  4. The updated floorplan svg is injected and displayed.
  5. The same sensor mdi icon should still be blinking (IF it has the SAME ID).

It would be complex to keep the changes in a separate list. Several users attempted to build such a solution for the old svg node, but they struggled with different things.

It might be better to keep all the changes in the virtual DOM tree. The only problem occurs when something is remvoed from the virtual DOM, because you cannot detect this change afterwards (unless the element is made invisible -> which is stored in a data field).