-
Notifications
You must be signed in to change notification settings - Fork 646
Improve PageLayout pane drag performance with pointer capture and GPU-accelerated transforms #7251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+881
−160
Merged
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
190058f
simple improvements
mattcosta7 44a815c
adds a queuing structure for raf throttling updates
mattcosta7 3cf401a
update body flag writing
mattcosta7 d25aaf1
Initial plan
Copilot 63599b8
Use setPointerCapture for drag and optimize width updates during mous…
Copilot cee9442
Fix race condition in drag delta tracking by using ref
Copilot f245cd8
Use GPU-accelerated transforms for drag preview instead of width updates
Copilot 219306b
Remove width from will-change since only transforms are used during drag
Copilot 296ef29
Use direct DOM style manipulation for drag delta to avoid React re-re…
Copilot 79685a9
Refactor: Extract CSS variable constant and helper function for delta…
Copilot e9d5f67
Use useImperativeHandle for ref synchronization instead of ref swapping
Copilot af4e09f
Simplify drag performance improvements
Copilot 340d3b5
Fix flush/cancel order in drag handlers
Copilot 8f75d75
simplify stable
mattcosta7 b86736a
simplify stable
mattcosta7 b069bfd
simplify stable
mattcosta7 c670f5f
simplify stable
mattcosta7 f71c9b0
simplify stable
mattcosta7 1b63444
frame
mattcosta7 8f9d1e5
constrain
mattcosta7 24ff5c5
mcss
mattcosta7 24ba053
smoother
mattcosta7 7770e63
updates
mattcosta7 80270a7
updates
mattcosta7 f165dd9
progressive fps
mattcosta7 6570bf3
update snapshots
mattcosta7 d4a7091
simplify a bit
mattcosta7 9782183
deop some unnecessary complexity
mattcosta7 fca99fe
deop some unnecessary complexity
mattcosta7 f190a07
improve a11y
mattcosta7 8d17ef7
improve perf
mattcosta7 d509a6b
more perf, less css reading
mattcosta7 4895a60
Update packages/react/src/PageLayout/PageLayout.tsx
mattcosta7 b21f28d
slight improvement
mattcosta7 585a67b
fix up some diff
mattcosta7 591e9ac
use-data-dragging instead of `isDragging`
mattcosta7 473e3f3
undo feature story change
mattcosta7 ccb20a8
perf story
mattcosta7 5de4de9
monitor
mattcosta7 d45b8c1
update
mattcosta7 f99ff5f
transition
mattcosta7 ce2d7cc
transition
mattcosta7 0cb267b
update pane width in effect
mattcosta7 1b68517
update pane width in effect
mattcosta7 8826fcc
pane width subscription
mattcosta7 3aff251
improve keyboard interaction
mattcosta7 d054588
improve keyboard interaction
mattcosta7 e1ff076
avoid name
mattcosta7 9dae955
comment
mattcosta7 4656eda
update css
mattcosta7 103c571
Merge branch 'main' into mc/copilot/sub-pr-7248
mattcosta7 bc5555c
changeset
mattcosta7 8fe1364
fix containment
mattcosta7 807e33a
Merge branch 'main' into mc/copilot/sub-pr-7248
mattcosta7 9a4003d
Merge branch 'main' into mc/copilot/sub-pr-7248
mattcosta7 3b04f70
remove onDragStart
mattcosta7 17fc2b5
backout test
mattcosta7 0c8bf15
Update packages/react/src/PageLayout/PageLayout.module.css
mattcosta7 22cfbf8
aat
mattcosta7 c8e7a06
aat
mattcosta7 94ef9c9
aat
mattcosta7 269155c
aat fix
mattcosta7 9d01862
handle frames softer
mattcosta7 dac73d2
remove perf header
mattcosta7 e93ccff
update snapshots
mattcosta7 66230cf
shave a few bytes on the handle checks
mattcosta7 bf13da9
cleanup a few bytes
mattcosta7 186ebc9
avoid heavy tests
mattcosta7 0029dfe
avoid heavy tests
mattcosta7 6844efd
fix vrt?
mattcosta7 e193e7d
Merge remote-tracking branch 'origin/main' into mc/copilot/sub-pr-7248
mattcosta7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| '@primer/react': patch | ||
| --- | ||
|
|
||
| Improve drag performance for PageLayout |
This file contains hidden or 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 hidden or 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,15 +1,3 @@ | ||||||||||||||||
| /* Maintain resize cursor while dragging */ | ||||||||||||||||
| /* stylelint-disable-next-line selector-no-qualifying-type */ | ||||||||||||||||
| body[data-page-layout-dragging='true'] { | ||||||||||||||||
| cursor: col-resize; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* Disable text selection while dragging */ | ||||||||||||||||
| /* stylelint-disable-next-line selector-no-qualifying-type */ | ||||||||||||||||
| body[data-page-layout-dragging='true'] * { | ||||||||||||||||
| user-select: none; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| .PageLayoutRoot { | ||||||||||||||||
| /* Region Order */ | ||||||||||||||||
| --region-order-header: 0; | ||||||||||||||||
|
|
@@ -357,6 +345,12 @@ body[data-page-layout-dragging='true'] * { | |||||||||||||||
| flex-grow: 1; | ||||||||||||||||
| flex-shrink: 1; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * OPTIMIZATION: Isolate content area from rest of page | ||||||||||||||||
| * Note: No 'paint' containment to allow overflow effects (tooltips, modals, etc.) | ||||||||||||||||
| */ | ||||||||||||||||
| contain: layout style; | ||||||||||||||||
|
|
||||||||||||||||
| &:where([data-is-hidden='true']) { | ||||||||||||||||
| display: none; | ||||||||||||||||
| } | ||||||||||||||||
|
|
@@ -383,6 +377,26 @@ body[data-page-layout-dragging='true'] * { | |||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * OPTIMIZATION: Aggressive containment during drag for ContentWrapper | ||||||||||||||||
| * CSS handles most optimizations automatically via :has() selector | ||||||||||||||||
| * JavaScript only handles scroll locking (can't be done in CSS) | ||||||||||||||||
| */ | ||||||||||||||||
| .PageLayoutContent:has(.DraggableHandle[data-dragging='true']) .ContentWrapper { | ||||||||||||||||
| /* Add paint containment during drag - safe since user can't interact */ | ||||||||||||||||
| contain: layout style paint; | ||||||||||||||||
|
|
||||||||||||||||
| /* Disable interactions */ | ||||||||||||||||
| pointer-events: none; | ||||||||||||||||
|
|
||||||||||||||||
| /* Disable transitions to prevent expensive recalculations */ | ||||||||||||||||
| transition: none; | ||||||||||||||||
|
|
||||||||||||||||
| /* Force compositor layer for hardware acceleration */ | ||||||||||||||||
| will-change: width; | ||||||||||||||||
| transform: translateZ(0); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| .Content { | ||||||||||||||||
| width: 100%; | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -392,6 +406,14 @@ body[data-page-layout-dragging='true'] * { | |||||||||||||||
| margin-left: auto; | ||||||||||||||||
| flex-grow: 1; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * OPTIMIZATION: Skip rendering off-screen content during scrolling/resizing | ||||||||||||||||
| * This automatically helps consumers with large content by only rendering | ||||||||||||||||
| * elements that are visible in the viewport | ||||||||||||||||
| */ | ||||||||||||||||
| content-visibility: auto; | ||||||||||||||||
|
||||||||||||||||
| content-visibility: auto; | |
| content-visibility: auto; | |
| /* | |
| * 500px was chosen as a reasonable estimate for the typical height of page content. | |
| * This helps browsers reserve space for off-screen content when using content-visibility: auto, | |
| * reducing layout shifts and scroll jumps. Adjust if your average content height differs significantly. | |
| */ |
mattcosta7 marked this conversation as resolved.
Show resolved
Hide resolved
mattcosta7 marked this conversation as resolved.
Show resolved
Hide resolved
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.