Skip to content

Commit

Permalink
fix: synced doc card lagging when dragging move
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone committed Jul 30, 2024
1 parent 1de26a9 commit 0c1d6d8
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { getSyncedDocIcons } from '../utils.js';

@customElement('affine-embed-synced-doc-card')
export class EmbedSyncedDocCard extends WithDisposable(ShadowlessElement) {
private _dragging = false;

static override styles = cardStyles;

cleanUpSurfaceRefRenderer = () => {
Expand Down Expand Up @@ -52,6 +54,21 @@ export class EmbedSyncedDocCard extends WithDisposable(ShadowlessElement) {
override connectedCallback() {
super.connectedCallback();

this.block.handleEvent(
'dragStart',
() => {
this._dragging = true;
},
{ global: true }
);
this.block.handleEvent(
'dragEnd',
() => {
this._dragging = false;
},
{ global: true }
);

const { isCycle } = this.block.blockState;
const syncedDoc = this.block.syncedDoc;
if (isCycle && syncedDoc) {
Expand All @@ -70,6 +87,9 @@ export class EmbedSyncedDocCard extends WithDisposable(ShadowlessElement) {
);
this.disposables.add(
syncedDoc.slots.blockUpdated.on(payload => {
if (this._dragging) {
return;
}
if (
payload.type === 'update' &&
['', 'caption', 'xywh'].includes(payload.props.key)
Expand Down

0 comments on commit 0c1d6d8

Please sign in to comment.