@jbrowse/plugin-linear-genome-view 4.2.0 → 4.2.1
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.
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import { memo } from 'react';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import { getContainingView } from '@jbrowse/core/util';
|
|
4
3
|
import { makeStyles } from '@jbrowse/core/util/tss-react';
|
|
5
4
|
import { observer } from 'mobx-react';
|
|
@@ -25,12 +24,6 @@ const useStyles = makeStyles()({
|
|
|
25
24
|
lineHeight: 1,
|
|
26
25
|
},
|
|
27
26
|
});
|
|
28
|
-
const FixedLabel = memo(function FixedLabel({ text, color, isOverlay, featureLeftPx, featureId, subfeatureId, y, tooltip, labelClass, overlayClass, }) {
|
|
29
|
-
return (_jsx("div", { "data-feature-id": featureId, "data-subfeature-id": subfeatureId, "data-tooltip": tooltip, className: isOverlay ? `${labelClass} ${overlayClass}` : labelClass, style: {
|
|
30
|
-
color,
|
|
31
|
-
transform: `translate(calc(${featureLeftPx}px - var(--offset-px)), ${y}px)`,
|
|
32
|
-
}, children: text }));
|
|
33
|
-
});
|
|
34
27
|
function FloatingLabel({ text, color, isOverlay, featureLeftPx, featureRightPx, featureId, subfeatureId, labelWidth, y, offsetPx, tooltip, labelClass, overlayClass, }) {
|
|
35
28
|
const x = calculateFloatingLabelPosition(featureLeftPx, featureRightPx, labelWidth, offsetPx);
|
|
36
29
|
return (_jsx("div", { "data-feature-id": featureId, "data-subfeature-id": subfeatureId, "data-tooltip": tooltip, className: isOverlay ? `${labelClass} ${overlayClass}` : labelClass, style: { color, transform: `translate(${x}px,${y}px)` }, children: text }));
|
|
@@ -41,8 +34,7 @@ const FloatingLabels = observer(function FloatingLabels({ model, }) {
|
|
|
41
34
|
const { offsetPx } = view;
|
|
42
35
|
const featureLabels = model.floatingLabelData;
|
|
43
36
|
const { onFeatureClick, onFeatureContextMenu, onMouseMove } = model.renderingProps();
|
|
44
|
-
const
|
|
45
|
-
const floatingLabels = [];
|
|
37
|
+
const labels = [];
|
|
46
38
|
for (const [key, { leftPx, topPx, totalFeatureHeight, floatingLabels: labelData, featureWidth, },] of featureLabels.entries()) {
|
|
47
39
|
const featureVisualBottom = topPx + totalFeatureHeight;
|
|
48
40
|
const featureRightPx = leftPx + featureWidth;
|
|
@@ -52,15 +44,10 @@ const FloatingLabels = observer(function FloatingLabels({ model, }) {
|
|
|
52
44
|
const y = featureVisualBottom + relativeY;
|
|
53
45
|
const labelKey = `${key}-${i}`;
|
|
54
46
|
const featureId = parentFeatureId ?? key;
|
|
55
|
-
|
|
56
|
-
fixedLabels.push(_jsx(FixedLabel, { text: text, color: color, isOverlay: isOverlay ?? false, featureLeftPx: leftPx, featureId: featureId, subfeatureId: subfeatureId, y: y, tooltip: tooltip, labelClass: classes.label, overlayClass: classes.overlay }, labelKey));
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
floatingLabels.push(_jsx(FloatingLabel, { text: text, color: color, isOverlay: isOverlay ?? false, featureLeftPx: leftPx, featureRightPx: featureRightPx, featureId: featureId, subfeatureId: subfeatureId, labelWidth: labelWidth, y: y, offsetPx: offsetPx, tooltip: tooltip, labelClass: classes.label, overlayClass: classes.overlay }, labelKey));
|
|
60
|
-
}
|
|
47
|
+
labels.push(_jsx(FloatingLabel, { text: text, color: color, isOverlay: isOverlay ?? false, featureLeftPx: leftPx, featureRightPx: featureRightPx, featureId: featureId, subfeatureId: subfeatureId, labelWidth: labelWidth, y: y, offsetPx: offsetPx, tooltip: tooltip, labelClass: classes.label, overlayClass: classes.overlay }, labelKey));
|
|
61
48
|
}
|
|
62
49
|
}
|
|
63
|
-
return (
|
|
50
|
+
return (_jsx("div", { className: classes.container, onClick: e => {
|
|
64
51
|
const target = e.target;
|
|
65
52
|
const subfeatureId = target.dataset.subfeatureId;
|
|
66
53
|
const featureId = subfeatureId ?? target.dataset.featureId;
|
|
@@ -83,6 +70,6 @@ const FloatingLabels = observer(function FloatingLabels({ model, }) {
|
|
|
83
70
|
onMouseMove?.(e, featureId, tooltip);
|
|
84
71
|
model.setSubfeatureIdUnderMouse(subfeatureId);
|
|
85
72
|
}
|
|
86
|
-
}, children:
|
|
73
|
+
}, children: labels }));
|
|
87
74
|
});
|
|
88
75
|
export default FloatingLabels;
|
|
@@ -80,10 +80,11 @@ export function deduplicateFeatureLabels(layoutFeatures, view, assembly, bpPerPx
|
|
|
80
80
|
if (leftPx === undefined) {
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
|
+
const floorLeftPx = Math.floor(leftPx);
|
|
83
84
|
const existing = featureLabels.get(key);
|
|
84
|
-
if (!existing ||
|
|
85
|
+
if (!existing || floorLeftPx < existing.leftPx) {
|
|
85
86
|
featureLabels.set(key, {
|
|
86
|
-
leftPx,
|
|
87
|
+
leftPx: floorLeftPx,
|
|
87
88
|
topPx: effectiveTopPx,
|
|
88
89
|
totalFeatureHeight,
|
|
89
90
|
floatingLabels,
|
|
@@ -96,11 +97,11 @@ export function deduplicateFeatureLabels(layoutFeatures, view, assembly, bpPerPx
|
|
|
96
97
|
export function calculateFloatingLabelPosition(featureLeftPx, featureRightPx, labelWidth, offsetPx) {
|
|
97
98
|
const featureWidth = featureRightPx - featureLeftPx;
|
|
98
99
|
if (labelWidth > featureWidth) {
|
|
99
|
-
return featureLeftPx - offsetPx;
|
|
100
|
+
return Math.round(featureLeftPx - offsetPx);
|
|
100
101
|
}
|
|
101
102
|
const viewportLeft = Math.max(0, offsetPx);
|
|
102
103
|
const leftPx = Math.max(featureLeftPx, viewportLeft);
|
|
103
104
|
const naturalX = leftPx - offsetPx;
|
|
104
105
|
const maxX = featureRightPx - offsetPx - labelWidth;
|
|
105
|
-
return clamp(naturalX, 0, maxX);
|
|
106
|
+
return Math.round(clamp(naturalX, 0, maxX));
|
|
106
107
|
}
|
|
@@ -20,7 +20,14 @@ export function setupInitAutorun(self) {
|
|
|
20
20
|
}
|
|
21
21
|
try {
|
|
22
22
|
if (init.loc) {
|
|
23
|
-
await
|
|
23
|
+
const asm = await assemblyManager.waitForAssembly(init.assembly);
|
|
24
|
+
if (!asm) {
|
|
25
|
+
throw new Error('Assembly not found');
|
|
26
|
+
}
|
|
27
|
+
await self.navToSearchString({
|
|
28
|
+
input: init.loc,
|
|
29
|
+
assembly: asm,
|
|
30
|
+
});
|
|
24
31
|
}
|
|
25
32
|
else {
|
|
26
33
|
self.showAllRegionsInAssembly(init.assembly);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-linear-genome-view",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "JBrowse 2 linear genome view",
|
|
6
6
|
"keywords": [
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"file-saver-es": "^2.0.5",
|
|
30
30
|
"mobx": "^6.15.0",
|
|
31
31
|
"mobx-react": "^9.2.1",
|
|
32
|
-
"@jbrowse/core": "^4.2.
|
|
33
|
-
"@jbrowse/product-core": "^4.2.
|
|
32
|
+
"@jbrowse/core": "^4.2.1",
|
|
33
|
+
"@jbrowse/product-core": "^4.2.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=18.0.0",
|