jbrowse-plugin-protein3d 0.5.4 → 0.5.5

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.
@@ -29,16 +29,30 @@ const ProteinAlignment = observer(function ProteinAlignment({ model, }) {
29
29
  const containerRef = useRef(null);
30
30
  const scrolledToSelectionRef = useRef(false);
31
31
  const { data: featureData, isLoading: featureLoading, error: featureError, } = useProteinFeatureTrackData(model, uniprotId);
32
+ // Follow the hovered column, but only when it has scrolled off-screen, and
33
+ // then only far enough to bring it back to the nearest edge. Re-centering on
34
+ // every hover (the old behavior) made the panel drift continuously as the
35
+ // cursor moved; scroll-into-view keeps it still whenever the column is
36
+ // already visible.
32
37
  useEffect(() => autorun(() => {
33
38
  const container = containerRef.current;
34
39
  if (model.autoScrollAlignment &&
35
40
  !model.isMouseInAlignment &&
36
41
  model.alignmentHoverPos !== undefined &&
37
42
  container) {
38
- container.scrollTo({
39
- left: model.alignmentHoverPos * CHAR_WIDTH - container.clientWidth / 2,
40
- behavior: 'smooth',
41
- });
43
+ const x = model.alignmentHoverPos * CHAR_WIDTH;
44
+ const margin = CHAR_WIDTH * 4;
45
+ const viewStart = container.scrollLeft;
46
+ const viewEnd = viewStart + container.clientWidth;
47
+ if (x < viewStart + margin) {
48
+ container.scrollTo({ left: x - margin, behavior: 'smooth' });
49
+ }
50
+ else if (x > viewEnd - margin) {
51
+ container.scrollTo({
52
+ left: x - container.clientWidth + margin,
53
+ behavior: 'smooth',
54
+ });
55
+ }
42
56
  }
43
57
  }), [model]);
44
58
  // Scroll the persistent selection into view once it first resolves, so a
@@ -47,7 +47,7 @@ function getDisplayToggles(model) {
47
47
  },
48
48
  },
49
49
  {
50
- label: 'Auto-scroll features',
50
+ label: 'Auto-scroll alignment',
51
51
  checked: model.autoScrollAlignment,
52
52
  onToggle: () => {
53
53
  model.setAutoScrollAlignment(!model.autoScrollAlignment);
@@ -426,7 +426,7 @@ function stateModelFactory() {
426
426
  },
427
427
  },
428
428
  {
429
- label: 'Auto-scroll protein feature view on hover',
429
+ label: 'Auto-scroll alignment to hovered position',
430
430
  type: 'checkbox',
431
431
  checked: self.autoScrollAlignment,
432
432
  onClick: () => {