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:
@@ -100,9 +100,18 @@ function _applyAnchor(el, container, saved) {
|
|||||||
el.style.left = l + 'px';
|
el.style.left = l + 'px';
|
||||||
el.style.top = t + 'px';
|
el.style.top = t + 'px';
|
||||||
}
|
}
|
||||||
/** Shorthand wrappers for minimap / toolbar. */
|
/** True when the graph container is in fullscreen — suppress anchor persistence. */
|
||||||
function _saveMinimapAnchored(el, container) { return _saveAnchored(el, container, _saveMinimapRect); }
|
function _isFullscreen() { return !!document.fullscreenElement; }
|
||||||
function _saveToolbarAnchored(el, container) { return _saveAnchored(el, container, _saveToolbarPos); }
|
|
||||||
|
/** 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
|
// Toolbar position persisted in localStorage
|
||||||
const _TB_KEY = 'graph_toolbar';
|
const _TB_KEY = 'graph_toolbar';
|
||||||
@@ -867,9 +876,14 @@ let _resizeObserver = null;
|
|||||||
function _initResizeClamp(container) {
|
function _initResizeClamp(container) {
|
||||||
if (_resizeObserver) _resizeObserver.disconnect();
|
if (_resizeObserver) _resizeObserver.disconnect();
|
||||||
_resizeObserver = new ResizeObserver(() => {
|
_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 mm = container.querySelector('.graph-minimap');
|
||||||
const tb = container.querySelector('.graph-toolbar');
|
const tb = container.querySelector('.graph-toolbar');
|
||||||
if (mm) {
|
if (mm) {
|
||||||
|
if (fs) {
|
||||||
|
_clampElementInContainer(mm, container);
|
||||||
|
} else {
|
||||||
const saved = _loadMinimapRect();
|
const saved = _loadMinimapRect();
|
||||||
if (saved?.anchor) {
|
if (saved?.anchor) {
|
||||||
_applyAnchor(mm, container, saved);
|
_applyAnchor(mm, container, saved);
|
||||||
@@ -877,7 +891,11 @@ function _initResizeClamp(container) {
|
|||||||
_clampElementInContainer(mm, container);
|
_clampElementInContainer(mm, container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (tb) {
|
if (tb) {
|
||||||
|
if (fs) {
|
||||||
|
_clampElementInContainer(tb, container);
|
||||||
|
} else {
|
||||||
const saved = _loadToolbarPos();
|
const saved = _loadToolbarPos();
|
||||||
if (saved?.anchor) {
|
if (saved?.anchor) {
|
||||||
_applyAnchor(tb, container, saved);
|
_applyAnchor(tb, container, saved);
|
||||||
@@ -885,6 +903,7 @@ function _initResizeClamp(container) {
|
|||||||
_clampElementInContainer(tb, container);
|
_clampElementInContainer(tb, container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
_resizeObserver.observe(container);
|
_resizeObserver.observe(container);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user