Fix anchor positions getting corrupted by fullscreen mode

Skip persisting minimap/toolbar anchor data while in fullscreen so
dragging during fullscreen doesn't overwrite normal-mode offsets.
ResizeObserver now just clamps during fullscreen instead of
re-applying normal-mode anchors to the fullscreen-sized container.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 18:43:07 +03:00
parent 39981fbc45
commit 8960e7dca3

View File

@@ -100,9 +100,18 @@ function _applyAnchor(el, container, saved) {
el.style.left = l + 'px';
el.style.top = t + 'px';
}
/** Shorthand wrappers for minimap / toolbar. */
function _saveMinimapAnchored(el, container) { return _saveAnchored(el, container, _saveMinimapRect); }
function _saveToolbarAnchored(el, container) { return _saveAnchored(el, container, _saveToolbarPos); }
/** True when the graph container is in fullscreen — suppress anchor persistence. */
function _isFullscreen() { return !!document.fullscreenElement; }
/** Shorthand wrappers for minimap / toolbar (skip save in fullscreen). */
function _saveMinimapAnchored(el, container) {
if (_isFullscreen()) return;
return _saveAnchored(el, container, _saveMinimapRect);
}
function _saveToolbarAnchored(el, container) {
if (_isFullscreen()) return;
return _saveAnchored(el, container, _saveToolbarPos);
}
// Toolbar position persisted in localStorage
const _TB_KEY = 'graph_toolbar';
@@ -867,22 +876,32 @@ let _resizeObserver = null;
function _initResizeClamp(container) {
if (_resizeObserver) _resizeObserver.disconnect();
_resizeObserver = new ResizeObserver(() => {
// In fullscreen, just clamp — don't re-anchor from normal-mode saved data
const fs = _isFullscreen();
const mm = container.querySelector('.graph-minimap');
const tb = container.querySelector('.graph-toolbar');
if (mm) {
const saved = _loadMinimapRect();
if (saved?.anchor) {
_applyAnchor(mm, container, saved);
} else {
if (fs) {
_clampElementInContainer(mm, container);
} else {
const saved = _loadMinimapRect();
if (saved?.anchor) {
_applyAnchor(mm, container, saved);
} else {
_clampElementInContainer(mm, container);
}
}
}
if (tb) {
const saved = _loadToolbarPos();
if (saved?.anchor) {
_applyAnchor(tb, container, saved);
} else {
if (fs) {
_clampElementInContainer(tb, container);
} else {
const saved = _loadToolbarPos();
if (saved?.anchor) {
_applyAnchor(tb, container, saved);
} else {
_clampElementInContainer(tb, container);
}
}
}
});