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

Feature/753/new focus unfocus functionality #3706

Merged
merged 15 commits into from
Sep 17, 2024

Conversation

IdrisLaabidi
Copy link
Contributor

@IdrisLaabidi IdrisLaabidi commented Sep 3, 2024

#Focus with zoom and camera animation

Issue: #753

Description

Focus Functionality:

  • Zooms in and centers on the desired nodes/packages.
  • Maintains the current camera angle (rotation) to provide a consistent visual context.
  • Smooth transition to enhance the user experience and make tracking clearer.

Unfocus Functionality:

  • Zooms out to the previous or default view.
  • Ensures the overall camera angle remains unchanged.
  • Smooth transition back to the broader view to maintain visual continuity.

Camera Animation:

  • Implemented smooth animations when switching between camera positions/angles.

Definition of Done

A PR is only ready for merge once all the following acceptance criteria are fulfilled:

  • Changes have been manually tested
  • All TODOs related to this PR have been closed
  • There are automated tests for newly written code and bug fixes
  • All bugs discovered while working on this PR have been submitted as issues (if not already an open issue)
  • Documentation (GH-pages, analysis/visualization READMEs, parser READMEs, --help, etc.) has been updated (almost always necessary except for bug fixes)
  • CHANGELOG.md has been updated

Screenshots or gifs

Copy link
Contributor

@Nereboss Nereboss left a comment

Choose a reason for hiding this comment

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

some smaller comments that should be addressed but looks good overall!

describe("FocusEffects", () => {
let actions$: BehaviorSubject<Action>
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let effects: FocusEffects
Copy link
Contributor

Choose a reason for hiding this comment

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

this variable is unused, can it be removed? (even if not, the comment above it should be)

this.threeMapControlsService.focusNode(newFocusedNodePath)
})
} else {
this.threeMapControlsService.focusNode(newFocusedNodePath)
Copy link
Contributor

Choose a reason for hiding this comment

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

This action is performed both inside the if and in the else part of the condition. Can it be moved outside or is that not pissible because its used as a callback in unfocusNode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Within the if statement, the callback function is invoked to allow the chaining of the unfocus and focus animations. Without this callback mechanism, only the focus action would need to be triggered directly.

this.threeMapControlsService.unfocusNode()
return
}
this.threeMapControlsService.unfocusNode()
Copy link
Contributor

Choose a reason for hiding this comment

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

this action is performed both as the first action in and right after the condition. Can it be moved before the condition? this would help with readability

@@ -94,7 +94,7 @@ export class CodeMapRenderService implements OnDestroy {
}

getVisibleNodes(nodes: Node[]) {
return nodes.filter(node => node.visible && node.length > 0 && node.width > 0).sort((a, b) => b.height - a.height)
return nodes.filter(node => node.length > 0 && node.width > 0).sort((a, b) => b.height - a.height)
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont know why the part that checks if a node is visible was removed and if that is necessary but if so, we should also rename the function accordingly as it no longer only returns visible nodes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking if a node is visible was a part of the old focus functionality, nodes that have visible attribute set to false won't be rendered. That's why it was removed

const initialPosition = threeCameraService.camera.position.clone()

threeMapControlsService.unfocusNode()
await wait(1100)
Copy link
Contributor

Choose a reason for hiding this comment

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

are wait times this long necessary here? this adds 2 seconds to every time the program is built

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the long waiting time is for the animation to finish

})

it("should not move the camera if positionBeforeFocus is not defined", async () => {
threeMapControlsService.positionBeforeFocus = undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

This test works even if i remove the line that sets positionBeforeFocus to undefined. Can this case even happen in a production setting?

Copy link
Contributor

@Nereboss Nereboss left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@IhsenBouallegue IhsenBouallegue left a comment

Choose a reason for hiding this comment

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

LGTM 🥇

Copy link

sonarcloud bot commented Sep 17, 2024

Copy link

sonarcloud bot commented Sep 17, 2024

@Nereboss Nereboss merged commit 52c5d9b into main Sep 17, 2024
7 checks passed
@Nereboss Nereboss deleted the feature/753/new-focus-unfocus-functionality branch September 17, 2024 12:25
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.

3 participants