Переглянути джерело

Fix visual visibility edge case

dsehnal 3 роки тому
батько
коміт
d9b4c60239

+ 1 - 0
CHANGELOG.md

@@ -10,6 +10,7 @@ Note that since we don't clearly distinguish between a public and private interf
 - Fix entity label not displayed when multiple instances of the same entity are highlighted
 - Fix empty elements created in ``StructureElement.Loci.extendToAllInstances``
 - Measurement options tweaks (allow larger ``textSize``; make ``customText`` essential)
+- Fix visual visibility sync edge case when changing state snapshots
 
 ## [v3.0.1] - 2022-01-27
 

+ 1 - 1
src/mol-plugin/behavior/static/representation.ts

@@ -84,7 +84,7 @@ export function UpdateRepresentationVisibility(ctx: PluginContext) {
 }
 
 function updateVisibility(cell: StateObjectCell, r: Representation<any>) {
-    if (r.state.visible === cell.state.isHidden) {
+    if (r.state.visible === !!cell.state.isHidden) {
         r.setState({ visible: !cell.state.isHidden });
         return true;
     } else {

+ 11 - 2
src/mol-state/transform.ts

@@ -76,14 +76,23 @@ namespace Transform {
             const s = (b as any)[k], t = (a as any)[k];
             if (!!s === !!t) continue;
             changed = true;
-            (a as any)[k] = s;
+            if (s !== void 0) {
+                (a as any)[k] = s;
+            } else {
+                delete (a as any)[k];
+            }
         }
         for (const k of Object.keys(a)) {
             const s = (b as any)[k], t = (a as any)[k];
             if (!!s === !!t) continue;
             changed = true;
-            (a as any)[k] = s;
+            if (s !== void 0) {
+                (a as any)[k] = s;
+            } else {
+                delete (a as any)[k];
+            }
         }
+
         return changed;
     }