-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Drop zone: rewrite with hooks (useDropZone) #19514
Changes from 1 commit
b082ca6
413e2aa
66e6b91
464e660
4032990
af10ad6
3868c40
9d3667b
4011f05
5f1fc4f
a3f8278
b1f2474
77cd3da
257a093
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,10 +143,15 @@ class DropZoneProvider extends Component { | |
if ( hoveredDropZone ) { | ||
const rect = hoveredDropZone.element.current.getBoundingClientRect(); | ||
|
||
position = { | ||
x: detail.clientX - rect.left < rect.right - detail.clientX ? 'left' : 'right', | ||
y: detail.clientY - rect.top < rect.bottom - detail.clientY ? 'top' : 'bottom', | ||
}; | ||
let x = detail.clientX; | ||
let y = detail.clientY; | ||
|
||
if ( ! hoveredDropZone.withExactPosition ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we just use another property like "coordinates" instead of hacking two different types in the same property? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally wouldn't, because it will make the component rerender much more, but I'm fine with it either way. We could remove the top/bottom calculation since they were specific for blocks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind dropping it too if not used. (dev note) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I removed them. :) |
||
x = detail.clientX - rect.left < rect.right - detail.clientX ? 'left' : 'right'; | ||
y = detail.clientY - rect.top < rect.bottom - detail.clientY ? 'top' : 'bottom'; | ||
} | ||
|
||
position = { x, y }; | ||
} | ||
|
||
// Optimisation: Only update the changed dropzones | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to take into consideration the blocks that are laid out horizontally (I'm not sure it was the case before)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not possible in
master
right now, so I'd prefer to tackle this in a separate PR to keep this small and contained.