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

refactor(layout): add Layout class and enums for canvas fit and align… #358

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samavati
Copy link
Contributor

Layout module refactor

Description

This pull request refactors the existing Layout class and related enums for managing the fit and alignment of Rive animations within an HTML canvas. The refactoring aims to improve code organization, maintainability, and adherence to best practices.

Changes

  • Move the Layout class to a dedicated file js/src/layout/Layout.ts
  • Move the Fit and Alignment enums to separate files within js/src/layout/enums/
  • Create a types directory within js/src/layout/ to house the LayoutParameters interface
  • Update import statements across the codebase to reflect the new file structure
  • Export the Layout class and enums from js/src/layout/index.ts
  • Update js/src/rive.ts to export the Layout class and enums

Benefits

  • Improved code organization and separation of concerns
  • Better adherence to the principle of single responsibility
  • Easier maintenance and extensibility of the Layout class and related types
  • Consistent import paths for the Layout class and enums across the codebase

Documentation

  • Existing documentation for the Layout class and enums has been updated to reflect the new file structure and import paths

Risks

No significant risks have been identified.

…ment

The Layout class provides methods to manage the fit and alignment of a Rive animation within an HTML canvas. It includes the following features:

- Fit enum with options: Cover, Contain, Fill, FitWidth, FitHeight, None, ScaleDown
- Alignment enum with options: Center, TopLeft, TopCenter, TopRight, CenterLeft, CenterRight, BottomLeft, BottomCenter, BottomRight
- Constructor to set layout parameters (fit, alignment, min/max X/Y coordinates)
- Methods to get runtime Fit and Alignment values for the Rive canvas
- Helper method to create a new Layout instance with modified parameters

This commit also exports the Layout class and enums from the rive.ts entry point.
@samavati
Copy link
Contributor Author

samavati commented Jul 1, 2024

Hi @HayesGordon ,

I haven't heard back about this pull request yet and I'm eager to get your feedback on the refactoring changes to the Layout class.

Thanks for your time!
Ehsan

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.

1 participant