feat: cam object fit #73
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes to the Cam Component’s object-fit
Previously, the
<Cam />component was hardcoded withobject-fit: cover, which forced the video to fill its container. This approach resulted in parts of the video being cropped—often giving a “zoomed-in” appearance.Key Changes
1. Dynamic object-fit via Props
Before:
The component always used object-fit: cover.
Now:
The component accepts an objectFit prop, allowing you to dynamically set the CSS property.
The video fills the container while maintaining its aspect ratio. If the container’s aspect ratio differs from the video, some parts of the video will be cropped.
The video is scaled to fit entirely within the container without cropping, potentially adding letterboxing (space).
2. Enhanced Flexibility
Context-Based Display:
You can now easily switch between a full-bleed immersive preview (cover) and a mode that displays the entire video frame (contain).
Adaptability:
This dynamic approach adapts the video display based on the application’s requirements or user preferences.
3. Separation of Concerns
Layout Management:
The parent container controls the overall layout and size.
Component Focus:
The component focuses solely on video rendering. This separation improves reusability and makes integration into various designs easier.
Example Usage
Below is an example of how to use the updated component with dynamic object-fit:
Summary
This change improves the overall flexibility of the component, ensuring that you can easily switch between different display modes to meet the needs of your application or user interface design.