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

Fix 2d graph over-rotating on node select #198

Merged
merged 3 commits into from
Mar 6, 2024
Merged

Conversation

ghsteff
Copy link
Contributor

@ghsteff ghsteff commented Mar 5, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

2d graphs over-rotate sometimes when selecting or de-selecting a node
Issue Number: #192

What is the new behavior?

2d graphs will rotate to the closest flat axis on node selection

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

BEFORE

Screen.Recording.2024-03-05.at.2.54.53.PM.mov

AFTER

Screen.Recording.2024-03-05.at.2.58.08.PM.mov

@ghsteff ghsteff requested a review from amcdnl March 5, 2024 23:00
@ghsteff ghsteff linked an issue Mar 5, 2024 that may be closed by this pull request
/**
* Get the closest axis to a given angle.
*/
export function getClosestAxis(angle: number, axes: number[]) {
Copy link
Member

Choose a reason for hiding this comment

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

Quick unit test please.

/**
* Get how far an angle is from the closest 2D axis in radians.
*/
export function getDegreesToClosest2dAxis(
Copy link
Member

Choose a reason for hiding this comment

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

Quick unit test please.

@@ -71,7 +71,13 @@ export const useCenterGraph = ({

// Check whether the layout is 3d or not to adjust centering logic
if (!layoutType.includes('3d')) {
void controls?.rotateTo(0, Math.PI / 2, true);
const { horizontalRotation, verticalRotation } =
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a description on what this is/why

@amcdnl amcdnl merged commit 031140c into master Mar 6, 2024
1 check passed
@amcdnl amcdnl deleted the fix/2d-graph-over-rotates branch March 6, 2024 09:44
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.

2D Graph over-rotates on node select
2 participants