Skip to content

Commit b8edcd6

Browse files
[Frontend] Corrected padding for zoom when window height changes OpenCTI-Platform#12313 (OpenCTI-Platform#12475)
1 parent d6fc3e4 commit b8edcd6

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

opencti-platform/opencti-front/src/components/graph/utils/useGraphInteractions.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,17 @@ const useGraphInteractions = () => {
7979
const zoomToFit = () => {
8080
const nbOfNodes = graphData?.nodes.length ?? 0;
8181
let padding = 50;
82-
if (nbOfNodes === 1) padding = 300;
83-
else if (nbOfNodes < 4) padding = 200;
82+
if (nbOfNodes === 1) {
83+
if (window.innerHeight < 600) {
84+
padding = 50;
85+
} else if (window.innerHeight < 900) {
86+
padding = 150;
87+
} else if (window.innerHeight < 1100) {
88+
padding = 300;
89+
} else {
90+
padding = 400;
91+
}
92+
} else if (nbOfNodes < 4) padding = 200;
8493
else if (nbOfNodes < 8) padding = 100;
8594
// Different padding depending on the number of nodes in the graph.
8695
graphRef2D.current?.zoomToFit(400, padding);

0 commit comments

Comments
 (0)