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(canvas): add #scrollToElement function #545

Merged
merged 2 commits into from
Apr 29, 2021
Merged

Conversation

marstamm
Copy link
Contributor

@marstamm marstamm commented Apr 22, 2021

  • adjust AutoPlace to scroll to new element
  • adjust SearchPad to use centralized function

related to camunda/camunda-modeler#1249
replaces bpmn-io/bpmn-js#1437
recording (3)

@bpmn-io-tasks bpmn-io-tasks bot added the in progress Currently worked on label Apr 22, 2021
@marstamm marstamm marked this pull request as ready for review April 22, 2021 12:00
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels Apr 22, 2021
@philippfromme philippfromme self-requested a review April 22, 2021 12:10
@philippfromme
Copy link
Contributor

Hint: It would have been nice to separate this PR into two commits, one that adds the new canvas method and one that adds the new scroll behavior. 😉

@marstamm
Copy link
Contributor Author

marstamm commented Apr 22, 2021

That makes sense, I followed the "one commit per PR" rule to closely 😄

EDIT: we do not have this rule, I just misunderstood the definition of done :D

@MaxTru
Copy link
Contributor

MaxTru commented Apr 22, 2021

That makes sense, I followed the "one commit per PR" rule to closely

EDIT: we do not have this rule, I just misunderstood the definition of done :D

When I was onboarded I had the same confusion because of the sentence a single commit closes the issue via Closes #issuenr in our https://github.com/bpmn-io/internal-docs/blob/master/development/DEFINITION_OF_DONE.md#definition-of-done.

Since we both had that confusion I propose to re-formulate it to say
the last commit in the PR closes the issue via Closes #issuenr

I will create a PR: https://github.com/bpmn-io/internal-docs/pull/268

@nikku
Copy link
Member

nikku commented Apr 22, 2021

Does not seem to work great when zoomed in or out yet. Also notice how in the search case you may want to provide a larger top padding to not hide behind the search widget / dropdown.

capture pOkQwz_optimized


capture Vi1H3r_optimized

@marstamm
Copy link
Contributor Author

Thank you for the hints 👍

I made the scrolling zoom-aware and added 400px top-padding when used in the search box

Copy link
Member

@nikku nikku left a comment

Choose a reason for hiding this comment

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

One last remark (and I hope we'll be done after this):

As you can see in the following screen capture the functionality is not stable (indempotent, whatever). If an element scrolled into origin once I'd assume further scrolling invocations to not scroll somewhere else.

This is an issue in the search case. Is it possible to address this?

capture KjwMvh_optimized

@marstamm
Copy link
Contributor Author

What would be the expected behavior when the element is to big to fit into view (with padding)? I would focus on the middle-top, as less get's hidden by UI elements and Sub-Process have the label there

@philippfromme
Copy link
Contributor

What would be the expected behavior when the element is to big to fit into view (with padding)?

I'd say, either center-center or top-left.

@marstamm
Copy link
Contributor Author

These are our options:
Center-Center
note that we center in the padded viewbox, so it looks off-center.
recording (4)

top-left
recording (5)

Top-Center
recording (6)

IMO, top-left looks better for Participants and Top-Center for Sub-processes. What do you prefer?

@nikku
Copy link
Member

nikku commented Apr 26, 2021

We need to keep in mind that this is not bpmn-js specific. Therefore I'd ignore the participant case and vote for top-center.

@philippfromme
Copy link
Contributor

I'd go for the very generic top-left, which always gives you a corner.

@marstamm
Copy link
Contributor Author

marstamm commented Apr 26, 2021

+1 for Philipp. Top-left also is the best when focusing on Flows while modeling left-right. For example in this model, every other method would focus on a point outside of the path:
image

Copy link
Contributor

@philippfromme philippfromme left a comment

Choose a reason for hiding this comment

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

Overall very good with nice test coverage. I've got a few remarks.

lib/core/Canvas.js Outdated Show resolved Hide resolved
lib/core/Canvas.js Outdated Show resolved Hide resolved
test/spec/core/CanvasSpec.js Outdated Show resolved Hide resolved
@nikku nikku self-requested a review April 27, 2021 13:53
Copy link
Member

@nikku nikku left a comment

Choose a reason for hiding this comment

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

Looks good from my perspective.

* scroll auto-placed elements into view
* use centralized method in SearchPad

related to camunda/camunda-modeler#1249
Copy link
Contributor

@philippfromme philippfromme left a comment

Choose a reason for hiding this comment

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

👏🏻

@fake-join fake-join bot merged commit 5896c3b into develop Apr 29, 2021
@fake-join fake-join bot deleted the scroll-into-view branch April 29, 2021 07:12
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants