-
Notifications
You must be signed in to change notification settings - Fork 13
feat: scroll moving block into view #451
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
Changes from 1 commit
726bdfe
2bc7d7c
6c8b345
140be72
9657acd
420c224
9019851
f78d28e
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 |
|---|---|---|
|
|
@@ -144,6 +144,8 @@ export class Mover { | |
| this.unpatchWorkspace(workspace); | ||
| this.unpatchDragStrategy(info.block); | ||
| this.moves.delete(workspace); | ||
| // Delay scroll until after block has finished moving. | ||
| setTimeout(() => this.scrollCurrentBlockIntoView(workspace), 0) | ||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -175,6 +177,8 @@ export class Mover { | |
| this.unpatchWorkspace(workspace); | ||
| this.unpatchDragStrategy(info.block); | ||
| this.moves.delete(workspace); | ||
| // Delay scroll until after block has finished moving. | ||
| setTimeout(() => this.scrollCurrentBlockIntoView(workspace), 0) | ||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -197,6 +201,7 @@ export class Mover { | |
| ); | ||
|
|
||
| info.updateTotalDelta(); | ||
| this.scrollCurrentBlockIntoView(workspace); | ||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -218,6 +223,7 @@ export class Mover { | |
| info.totalDelta.y += y * UNCONSTRAINED_MOVE_DISTANCE * workspace.scale; | ||
|
|
||
| info.dragger.onDrag(info.fakePointerEvent('pointermove'), info.totalDelta); | ||
| this.scrollCurrentBlockIntoView(workspace); | ||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -307,6 +313,20 @@ export class Mover { | |
| this.oldDragStrategy = null; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Scrolls the current block into view if exists one. | ||
| * | ||
| * @param workspace The workspace to get current block from. | ||
| */ | ||
| private scrollCurrentBlockIntoView(workspace: WorkspaceSvg) { | ||
|
||
| const blockToView = this.getCurrentBlock(workspace); | ||
| if (blockToView) { | ||
| workspace.scrollBoundsIntoView( | ||
| blockToView.getBoundingRectangleWithoutChildren(), | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.