-
-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean it up and document it at least
- Loading branch information
Showing
7 changed files
with
79 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// A div that overlays the whole inventory to block hit-testing during drag. | ||
// Note the z-index which should be above all other elements. Except for the | ||
// sub-bucket overlays. | ||
.dragPerfFix { | ||
// to test, set a nonzero opacity and a background color | ||
opacity: 0; | ||
|
||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
|
||
z-index: 8; | ||
|
||
display: none; | ||
|
||
.dragPerfShow & { | ||
display: block; | ||
} | ||
} | ||
|
||
// Each sub-bucket (inventory drag target) gets its own overlay as well, with a | ||
// z-index one higher than the global overlay. This allows them to still receive | ||
// drag events. | ||
:global(.sub-bucket) { | ||
&::before { | ||
content: ''; | ||
|
||
// to test, set a nonzero opacity and a background color | ||
opacity: 0; | ||
width: 100%; | ||
height: 100%; | ||
position: absolute; | ||
|
||
z-index: 9; | ||
|
||
display: none; | ||
|
||
.dragPerfShow & { | ||
display: block; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
import './DragPerformanceFix.scss'; | ||
import styles from './DragPerformanceFix.m.scss'; | ||
|
||
function hideOverlay() { | ||
/** | ||
* This is a workaround for sluggish dragging in Chrome on Windows. It may or | ||
* may not be related to Logitech mouse drivers or high-DPI mice, but in Chrome | ||
* on Windows only, some users experience a problem where they can drag items, | ||
* but the drag targets do not get events very quickly, so it may take a second | ||
* or two of hovering over a drop target to make it light up. This was still a | ||
* problem as of January 2025. | ||
* | ||
* This workaround is to put a full-screen invisible div over the entire app, | ||
* and then put separate invisible divs over each drop target. That simplifies | ||
* the hit-testing Chrome has to do, and makes dragging feel normal. | ||
*/ | ||
export default function DragPerformanceFix() { | ||
// Rarely (possibly never in typical usage), a browser will forget to dispatch the dragEnd event | ||
// So we try not to trap the user here. | ||
document.body.classList.remove('drag-perf-show'); | ||
// So we try not to trap the user here by allowing them to click away the overlay. | ||
return <div className={styles.dragPerfFix} onClick={hideDragFixOverlay} />; | ||
} | ||
|
||
/** This is a workaround for sluggish dragging in Chrome (and possibly other browsers) */ | ||
export default function DragPerformanceFix() { | ||
return <div className="drag-perf-fix" onClick={hideOverlay} />; | ||
export function showDragFixOverlay() { | ||
document.body.classList.add(styles.dragPerfShow); | ||
} | ||
|
||
export function hideDragFixOverlay() { | ||
document.body.classList.remove(styles.dragPerfShow); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters