Skip to content
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

[FEAT] Fit center the viewport on diagram load #836

Merged
merged 4 commits into from
Oct 29, 2020

Conversation

csouchet
Copy link
Member

@csouchet csouchet commented Oct 26, 2020

Covers #775

@csouchet csouchet added enhancement New feature or request depends on another PR ⚠️ Pull request depending on another one. The depending must be merged first BPMN diagram usability Something about the way we can interact with BPMN diagrams labels Oct 26, 2020
@csouchet csouchet force-pushed the 775-Center_fit_the_viewport_on_diagram_load branch 11 times, most recently from 47f34e8 to 25908e0 Compare October 27, 2020 15:55
@csouchet csouchet force-pushed the 775-Center_fit_the_viewport_on_diagram_load branch 6 times, most recently from 65503cc to 8be617b Compare October 28, 2020 16:06
@csouchet csouchet force-pushed the 775-Center_fit_the_viewport_on_diagram_load branch from 8be617b to ec59649 Compare October 28, 2020 16:43
@csouchet csouchet removed the depends on another PR ⚠️ Pull request depending on another one. The depending must be merged first label Oct 28, 2020
@csouchet csouchet marked this pull request as ready for review October 28, 2020 16:44
src/component/Options.ts Outdated Show resolved Hide resolved
src/component/mxgraph/BpmnMxGraph.ts Outdated Show resolved Hide resolved
const width = bounds.width / this.view.scale;
const height = bounds.height / this.view.scale;
const scale = Math.min(max, Math.min(clientWidth / width, clientHeight / height));
this.cumulativeZoomFactor = scale;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is required for consistency with the zoom code.
Do we need automatic test for that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should have a test who mix zoom & fit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be managed with #844

Copy link
Contributor

@aibcmars aibcmars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

csouchet and others added 2 commits October 29, 2020 09:34
Co-authored-by: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com>
@csouchet csouchet force-pushed the 775-Center_fit_the_viewport_on_diagram_load branch from a12ec9a to ed0dd98 Compare October 29, 2020 10:40
@tbouffard tbouffard added the question Further information is requested label Oct 29, 2020
@@ -31,7 +31,7 @@ interface MouseWheelOptions {
*/
deltaY?: number;
}
interface MouseWithWheel extends Mouse {
export interface MouseWithWheel extends Mouse {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ we should probably put this definition in a dedicated file to avoid dependencies between test files whereas they have no relation

viewportCenterY = bounding_box.y + bounding_box.height / 2;
});

it(`ctrl + mouse: initial scale after zoom in and zoom out`, async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ I don't understand the title
It seems to me that we do fit on load then zoom. Is that correct? if so, the title is not clear IMHO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, we will work on this with #844

@tbouffard tbouffard merged commit aea79c8 into master Oct 29, 2020
@tbouffard tbouffard deleted the 775-Center_fit_the_viewport_on_diagram_load branch October 29, 2020 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BPMN diagram usability Something about the way we can interact with BPMN diagrams enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants