Skip to content
Snippets Groups Projects
Unverified Commit 75f27484 authored by Paul Kaplan's avatar Paul Kaplan Committed by GitHub
Browse files

Merge pull request #1001 from paulkaplan/keep-new-input-in-view

Try to keep new custom procedure inputs in view
parents 7d2aef0e 81c41f06
No related branches found
No related tags found
No related merge requests found
...@@ -49,8 +49,13 @@ class CustomProcedures extends React.Component { ...@@ -49,8 +49,13 @@ class CustomProcedures extends React.Component {
// Keep the block centered on the workspace // Keep the block centered on the workspace
const metrics = this.workspace.getMetrics(); const metrics = this.workspace.getMetrics();
const {x, y} = this.mutationRoot.getRelativeToSurfaceXY(); const {x, y} = this.mutationRoot.getRelativeToSurfaceXY();
const dx = (metrics.viewWidth / 2) - (this.mutationRoot.width / 2) - x;
const dy = (metrics.viewHeight / 2) - (this.mutationRoot.height / 2) - y; const dy = (metrics.viewHeight / 2) - (this.mutationRoot.height / 2) - y;
let dx = (metrics.viewWidth / 2) - (this.mutationRoot.width / 2) - x;
// If the procedure declaration is wider than the view width,
// keep the right-hand side of the procedure in view.
if (this.mutationRoot.width > metrics.viewWidth) {
dx = metrics.viewWidth - this.mutationRoot.width - x;
}
this.mutationRoot.moveBy(dx, dy); this.mutationRoot.moveBy(dx, dy);
}); });
this.mutationRoot.domToMutation(this.props.mutator); this.mutationRoot.domToMutation(this.props.mutator);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment