mirror of
https://github.com/Boof2015/prism.git
synced 2026-08-12 05:10:51 +02:00
fix window snap issue
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useLayoutEffect, useMemo, useRef, type CSSProperties, type JSX } from 'react'
|
||||
import { buildAnalyzerGridTemplateColumns } from '../analyzerLayout'
|
||||
import { resolveMainWindowSettingsPanelHeight } from '../mainWindowSettings'
|
||||
import ScopeSettingsSection from './ScopeSettingsSection'
|
||||
import { useSettingsStore } from '../stores/settingsStore'
|
||||
|
||||
@@ -31,7 +32,7 @@ export default function SettingsPanel({ onHeightChange }: SettingsPanelProps): J
|
||||
const reportHeight = (): void => {
|
||||
cancelAnimationFrame(frameId)
|
||||
frameId = requestAnimationFrame(() => {
|
||||
onHeightChange(Math.ceil(panelElement.scrollHeight))
|
||||
onHeightChange(resolveMainWindowSettingsPanelHeight(panelElement, scopeTrackRef.current))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
function parseCssPixels(value: string): number {
|
||||
const parsed = Number.parseFloat(value)
|
||||
return Number.isFinite(parsed) ? parsed : 0
|
||||
}
|
||||
|
||||
export function resolveMainWindowSettingsPanelHeight(
|
||||
panelElement: HTMLElement,
|
||||
contentElement: HTMLElement | null,
|
||||
): number {
|
||||
if (!contentElement) {
|
||||
return Math.ceil(panelElement.scrollHeight)
|
||||
}
|
||||
|
||||
const panelStyle = getComputedStyle(panelElement)
|
||||
const verticalPadding = parseCssPixels(panelStyle.paddingTop)
|
||||
+ parseCssPixels(panelStyle.paddingBottom)
|
||||
|
||||
return Math.ceil(contentElement.scrollHeight + verticalPadding)
|
||||
}
|
||||
|
||||
export function resolveMainWindowSettingsHeight(
|
||||
settingsOpen: boolean,
|
||||
settingsPanelHeight: number,
|
||||
|
||||
Reference in New Issue
Block a user