Skip to content

Commit

Permalink
Update workspace_svg.ts
Browse files Browse the repository at this point in the history
Added a programatic scrolling API to the workspace
  • Loading branch information
SophieNguyen113 authored Sep 22, 2023
1 parent a4067aa commit 3ecf5d6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/workspace_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,26 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
return this.scale;
}

// Add two new methods to WorkspaceSvg

/**
* Scroll the workspace horizontally by a relative amount.
* @param {number} deltaX Pixels to scroll horizontally.
*/
workspace.scrollHorizontal(deltaX) {
// Use existing scroll method with updated x
this.scroll(this.scrollX + deltaX, this.scrollY);
}

/**
* Scroll the workspace vertically by a relative amount.
* @param {number} deltaY Pixels to scroll vertically.
*/
workspace.scrollVertical(deltaY) {
// Use existing scroll method with updated y
this.scroll(this.scrollX, this.scrollY + deltaY);
}

/**
* Scroll the workspace to a specified offset (in pixels), keeping in the
* workspace bounds. See comment on workspaceSvg.scrollX for more detail on
Expand Down

0 comments on commit 3ecf5d6

Please sign in to comment.