From 710c5fb4eee554e378e0e08316ff7866204dd78a Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 25 Jul 2024 19:55:38 +0300 Subject: [PATCH] UI: Improve wheel valve SCADA symbol animation. --- .../scada_symbols/horizontal-wheel-valve.svg | 41 +++++-------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/application/src/main/data/json/system/scada_symbols/horizontal-wheel-valve.svg b/application/src/main/data/json/system/scada_symbols/horizontal-wheel-valve.svg index 1373c48df7..9fc03dd69a 100644 --- a/application/src/main/data/json/system/scada_symbols/horizontal-wheel-valve.svg +++ b/application/src/main/data/json/system/scada_symbols/horizontal-wheel-valve.svg @@ -1,6 +1,5 @@ - - - { +<svg xmlns="http://www.w3.org/2000/svg" xmlns:tb="https://thingsboard.io/svg" width="400" height="200" fill="none" version="1.1" viewBox="0 0 400 200"> +<tb:metadata xmlns=""><![CDATA[{ "title": "Horizontal wheel valve", "description": "Horizontal wheel valve with open/close animation and state colors.", "searchTags": [ @@ -12,7 +11,7 @@ "tags": [ { "tag": "background", - "stateRenderFunction": "var opened = ctx.values.opened;\nvar elementOpened = element.remember('opened');\nvar color = opened ? ctx.properties.openedColor : ctx.properties.closedColor;\nif (typeof elementOpened === 'undefined') {\n element.attr({fill: color});\n} else if (elementOpened !== opened) {\n ctx.api.animate(element, 500).attr({fill: color});\n}\nelement.remember('opened', opened);", + "stateRenderFunction": "var opened = ctx.values.opened;\nvar openAnimate = element.remember('openAnimate');\nvar color = opened ? ctx.properties.openedColor : ctx.properties.closedColor;\nif (!openAnimate) {\n element.attr({fill: color});\n} else {\n ctx.api.animate(element, 500).attr({fill: color});\n element.remember('openAnimate', false);\n}\n", "actions": null }, { @@ -20,13 +19,13 @@ "stateRenderFunction": null, "actions": { "click": { - "actionFunction": "var opened = ctx.values.opened;\nvar action = opened ? 'close' : 'open';\n\nctx.api.callAction(event, action, undefined, {\n next: () => {\n ctx.api.setValue('opened', !opened);\n }\n});" + "actionFunction": " ctx.tags.wheel.forEach(e => {\n e.remember('openAnimate', true);\n });\n ctx.tags.background.forEach(e => {\n e.remember('openAnimate', true);\n });\n\n\nvar opened = ctx.values.opened;\nvar action = opened ? 'close' : 'open';\n\nctx.api.callAction(event, action, undefined, {\n next: () => {\n ctx.api.setValue('opened', !opened);\n }\n});" } } }, { "tag": "wheel", - "stateRenderFunction": "var opened = ctx.values.opened;\nvar elementOpened = element.remember('opened');\nvar angle = opened ? ctx.properties.openedRotationAngle : ctx.properties.closedRotationAngle;\nif (typeof elementOpened === 'undefined') {\n element.transform({rotate: angle});\n} else if (elementOpened !== opened) {\n ctx.api.animate(element, 500).transform({rotate: angle});\n}\nelement.remember('opened', opened);", + "stateRenderFunction": "var opened = ctx.values.opened;\nvar openAnimate = element.remember('openAnimate');\nvar angle = opened ? ctx.properties.openedRotationAngle : ctx.properties.closedRotationAngle;\nif (!openAnimate) {\n element.transform({rotate: angle});\n} else {\n ctx.api.animate(element, 500).transform({rotate: angle});\n element.remember('openAnimate', false);\n}\n", "actions": null } ], @@ -143,35 +142,18 @@ "step": null } ] -} - - - - - - - - - - +}]]> - - + - - - + - - - - - + @@ -256,6 +238,5 @@ - - - + + \ No newline at end of file