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

remove label on mouseleave in state tree

Alexander Rose 5 роки тому
батько
коміт
9866db9ced
1 змінених файлів з 5 додано та 4 видалено
  1. 5 4
      src/mol-plugin/util/loci-label-manager.ts

+ 5 - 4
src/mol-plugin/util/loci-label-manager.ts

@@ -8,6 +8,7 @@
 import { PluginContext } from '../../mol-plugin/context';
 import { PluginContext } from '../../mol-plugin/context';
 import { Loci } from '../../mol-model/loci';
 import { Loci } from '../../mol-model/loci';
 import { Representation } from '../../mol-repr/representation';
 import { Representation } from '../../mol-repr/representation';
+import { MarkerAction } from '../../mol-util/marker-action';
 
 
 export type LociLabelEntry = JSX.Element | string
 export type LociLabelEntry = JSX.Element | string
 export type LociLabelProvider = (info: Loci, repr?: Representation<any>) => LociLabelEntry | undefined
 export type LociLabelProvider = (info: Loci, repr?: Representation<any>) => LociLabelEntry | undefined
@@ -24,9 +25,9 @@ export class LociLabelManager {
         // Event.Interactivity.Highlight.dispatch(this.ctx, []);
         // Event.Interactivity.Highlight.dispatch(this.ctx, []);
     }
     }
 
 
-    private empty: any[] = [];
-    private getInfo({ loci, repr }: Representation.Loci) {
-        if (!loci || loci.kind === 'empty-loci') return this.empty;
+    private empty: LociLabelEntry[] = [];
+    private getInfo({ loci, repr }: Representation.Loci, action: MarkerAction) {
+        if (Loci.isEmpty(loci) || action !== MarkerAction.Highlight) return this.empty;
         const info: LociLabelEntry[] = [];
         const info: LociLabelEntry[] = [];
         for (let p of this.providers) {
         for (let p of this.providers) {
             const e = p(loci, repr);
             const e = p(loci, repr);
@@ -36,6 +37,6 @@ export class LociLabelManager {
     }
     }
 
 
     constructor(public ctx: PluginContext) {
     constructor(public ctx: PluginContext) {
-        ctx.interactivity.lociHighlights.addProvider((loci) => ctx.behaviors.labels.highlight.next({ entries: this.getInfo(loci) }))
+        ctx.interactivity.lociHighlights.addProvider((loci, action) => ctx.behaviors.labels.highlight.next({ entries: this.getInfo(loci, action) }))
     }
     }
 }
 }