mirror of
https://github.com/outline/outline.git
synced 2026-12-03 18:10:36 +03:00
fix: Drag handle lags behind scroll position (#14108)
* fix: Drag handle lags behind scroll position * fix: Keep hidden or offscreen drag handle out of page layout
This commit is contained in:
1 parent
c78671e9f8
commit
2a347cc4d3
2 files changed
+25
-11
No files matched your search
@@ -197,13 +197,29 @@ export default class DragHandle extends Extension {
|
||||
// :dir(rtl) handling.
|
||||
const isRTL =
|
||||
window.getComputedStyle(next.element).direction === "rtl";
|
||||
handle.style.top =
|
||||
const top =
|
||||
lineMiddle === null
|
||||
? `${rect.top - ICON_OFFSET_Y}px`
|
||||
: `${lineMiddle - ICON_CENTER_Y}px`;
|
||||
handle.style.left = isRTL
|
||||
? `${rect.right + offsetX - HANDLE_SIZE}px`
|
||||
: `${rect.left - offsetX}px`;
|
||||
? rect.top - ICON_OFFSET_Y
|
||||
: lineMiddle - ICON_CENTER_Y;
|
||||
const left = isRTL
|
||||
? rect.right + offsetX - HANDLE_SIZE
|
||||
: rect.left - offsetX;
|
||||
|
||||
// Hide the handle past the viewport edge, such as when an inner
|
||||
// scroll container clips its block, so it does not grow the page.
|
||||
const { clientWidth, clientHeight } = document.documentElement;
|
||||
if (
|
||||
top + HANDLE_SIZE > clientHeight ||
|
||||
left + HANDLE_SIZE > clientWidth
|
||||
) {
|
||||
handle.classList.remove("visible", "dragging");
|
||||
return;
|
||||
}
|
||||
|
||||
// Position in document coordinates so that the browser scrolls
|
||||
// the handle with the page, rather than after the scroll event.
|
||||
handle.style.top = `${top + window.scrollY}px`;
|
||||
handle.style.left = `${left + window.scrollX}px`;
|
||||
handle.classList.remove("dragging");
|
||||
handle.classList.add("visible");
|
||||
};
|
||||
|
||||
@@ -184,12 +184,11 @@ export default createGlobalStyle<Props>`
|
||||
appearance: none;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
cursor: grab;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
display: none;
|
||||
transition: background-color 150ms ease-in-out;
|
||||
background-color: ${s("textTertiary")};
|
||||
mask-image: url("${dragHandleIcon}");
|
||||
@@ -206,8 +205,7 @@ export default createGlobalStyle<Props>`
|
||||
}
|
||||
|
||||
&.visible {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
&.visible.dragging {
|
||||
|
||||
Reference in new issue
Block a user