Skip to content

Commit e50ea06

Browse files
committed
Preview height issue fixed.
1 parent 2f8caea commit e50ea06

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/CodeSnippetDisplay.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,18 @@ export class CodeSnippetDisplay extends React.Component<
535535
private _setPreviewPosition(id: string): void {
536536
const intID = parseInt(id, 10);
537537
const realTarget = document.getElementsByClassName(TITLE_CLASS)[intID];
538+
const newTarget = document.getElementsByClassName('jp-codeSnippet-item')[
539+
intID
540+
];
538541
// distDown is the number of pixels to shift the preview down
539542
const distDown: number = realTarget.getBoundingClientRect().top - 43; //this is bumping it up
543+
const elementSnippet = newTarget as HTMLElement;
544+
const heightSnippet = elementSnippet.clientHeight;
545+
const heightPreview = heightSnippet.toString(10) + 'px';
546+
document.documentElement.style.setProperty(
547+
'--preview-max-height',
548+
heightPreview
549+
);
540550
// if (realTarget.getBoundingClientRect().top > window.screen.height / 2) {
541551
// distDown = distDown - 66; //this is bumping it up further if it's close to the end of the screen
542552
// }

style/index.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
:root {
22
--preview-distance: 0px;
3+
--preview-max-height: 75px;
34
--more-options-top: 0px;
45
--more-options-left: 0px;
56
}
@@ -179,7 +180,7 @@
179180
padding: 5px;
180181
width: 180px;
181182
height: fit-content;
182-
max-height: 75px;
183+
max-height: var(--preview-max-height);
183184
/*height: 106px;*/
184185
box-sizing: border-box;
185186
box-shadow: var(--jp-elevation-z2);

0 commit comments

Comments
 (0)