mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-24 05:07:06 +08:00
fix: drag block issue (#9902)
### Changed - Added support for changing the preview offset during dragging. - Fixed the preview rendering for embed block and surface-ref block - Resolved an issue where the host element might be reused in certain cases, which could cause unexpected behavior - Moved viewport-related constants and methods to a more appropriate location
This commit is contained in:
@@ -617,7 +617,7 @@ export class DragEventWatcher {
|
||||
onDrop: () => {
|
||||
this._cleanup();
|
||||
},
|
||||
setDragPreview: ({ source, container }) => {
|
||||
setDragPreview: ({ source, container, setOffset }) => {
|
||||
if (!source.data?.bsEntity?.modelIds.length) {
|
||||
return;
|
||||
}
|
||||
@@ -626,6 +626,9 @@ export class DragEventWatcher {
|
||||
source.data?.bsEntity?.modelIds,
|
||||
container
|
||||
);
|
||||
|
||||
const rect = container.getBoundingClientRect();
|
||||
setOffset({ x: rect.width / 2, y: rect.height / 2 });
|
||||
},
|
||||
setDragData: () => {
|
||||
const { snapshot } = this._getSnapshotFromHoveredBlocks();
|
||||
|
||||
Reference in New Issue
Block a user