From aacbe4db62134a904426a8887151feb1dc77a4b1 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 4 Aug 2022 22:50:15 +0000 Subject: [PATCH] refactor: remove AnyDuringMigration from bubble dragger (#6305) * fix: remove unnecessary disposing * fix: add nullability union to drag surface * chore: format * fix: remove no-op dispose method --- core/bubble_dragger.ts | 43 ++++++++---------------------------------- core/gesture.ts | 3 --- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/core/bubble_dragger.ts b/core/bubble_dragger.ts index d23798082..789cfa0ff 100644 --- a/core/bubble_dragger.ts +++ b/core/bubble_dragger.ts @@ -46,7 +46,7 @@ export class BubbleDragger { /** Whether the bubble would be deleted if dropped immediately. */ private wouldDeleteBubble_ = false; private readonly startXY_: Coordinate; - private dragSurface_: BlockDragSurfaceSvg; + private dragSurface_: BlockDragSurfaceSvg|null; /** * @param bubble The item on the bubble canvas to drag. @@ -63,29 +63,10 @@ export class BubbleDragger { * The drag surface to move bubbles to during a drag, or null if none should * be used. Block dragging and bubble dragging use the same surface. */ - // AnyDuringMigration because: Type 'BlockDragSurfaceSvg | null' is not - // assignable to type 'BlockDragSurfaceSvg'. this.dragSurface_ = - (svgMath.is3dSupported() && !!workspace.getBlockDragSurface() ? - workspace.getBlockDragSurface() : - null) as AnyDuringMigration; - } - - /** - * Sever all links from this object. - * @suppress {checkTypes} - * @internal - */ - dispose() { - // AnyDuringMigration because: Type 'null' is not assignable to type - // 'IBubble'. - this.bubble = null as AnyDuringMigration; - // AnyDuringMigration because: Type 'null' is not assignable to type - // 'WorkspaceSvg'. - this.workspace = null as AnyDuringMigration; - // AnyDuringMigration because: Type 'null' is not assignable to type - // 'BlockDragSurfaceSvg'. - this.dragSurface_ = null as AnyDuringMigration; + svgMath.is3dSupported() && !!workspace.getBlockDragSurface() ? + workspace.getBlockDragSurface() : + null; } /** @@ -100,7 +81,10 @@ export class BubbleDragger { this.workspace.setResizesEnabled(false); this.bubble.setAutoLayout(false); if (this.dragSurface_) { - this.moveToDragSurface_(); + this.bubble.moveTo(0, 0); + this.dragSurface_.translateSurface(this.startXY_.x, this.startXY_.y); + // Execute the move on the top-level SVG component. + this.dragSurface_.setBlocksAndShow(this.bubble.getSvgRoot()); } this.bubble.setDragging && this.bubble.setDragging(true); @@ -242,15 +226,4 @@ export class BubbleDragger { } return result; } - - /** - * Move the bubble onto the drag surface at the beginning of a drag. Move the - * drag surface to preserve the apparent location of the bubble. - */ - private moveToDragSurface_() { - this.bubble.moveTo(0, 0); - this.dragSurface_.translateSurface(this.startXY_.x, this.startXY_.y); - // Execute the move on the top-level SVG component. - this.dragSurface_.setBlocksAndShow(this.bubble.getSvgRoot()); - } } diff --git a/core/gesture.ts b/core/gesture.ts index caf42ec78..94b9dfc06 100644 --- a/core/gesture.ts +++ b/core/gesture.ts @@ -211,9 +211,6 @@ export class Gesture { if (this.workspaceDragger_) { this.workspaceDragger_.dispose(); } - if (this.bubbleDragger_) { - this.bubbleDragger_.dispose(); - } } /**