jbrowse-plugin-protein3d 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,6 +27,7 @@ function GutterLabel({ label, title, height, }) {
27
27
  const ProteinAlignment = observer(function ProteinAlignment({ model, }) {
28
28
  const { pairwiseAlignment, showHighlight, showProteinTracks, uniprotId, confidenceCells, hydrophobicityCells, } = model;
29
29
  const containerRef = useRef(null);
30
+ const scrolledToSelectionRef = useRef(false);
30
31
  const { data: featureData, isLoading: featureLoading, error: featureError, } = useProteinFeatureTrackData(model, uniprotId);
31
32
  useEffect(() => autorun(() => {
32
33
  const container = containerRef.current;
@@ -40,6 +41,19 @@ const ProteinAlignment = observer(function ProteinAlignment({ model, }) {
40
41
  });
41
42
  }
42
43
  }), [model]);
44
+ // Scroll the persistent selection into view once it first resolves, so a
45
+ // declarative `initialSelection` (or any off-screen selection) shows its
46
+ // highlight band instead of opening scrolled to the N-terminus. Guarded to
47
+ // fire once, so it doesn't fight the user's own scrolling afterward.
48
+ useEffect(() => autorun(() => {
49
+ const container = containerRef.current;
50
+ const range = model.clickAlignmentRange;
51
+ if (container && range && !scrolledToSelectionRef.current) {
52
+ scrolledToSelectionRef.current = true;
53
+ const mid = ((range.start + range.end) / 2) * CHAR_WIDTH;
54
+ container.scrollTo({ left: mid - container.clientWidth / 2 });
55
+ }
56
+ }), [model]);
43
57
  if (!pairwiseAlignment) {
44
58
  return React.createElement("div", null, "No pairwiseAlignment");
45
59
  }