-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[RFC] Responsive fill mode #7645
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
Comments
Sounds great! |
But isn't it the same as FILLMODE_FILL_WINDOW ? |
Not quite, |
In CSS terms, this is called "relative", so could be called "FILLMODE_RELATIVE". For width and height being 100%, does it require a parent element's style to have at least |
If I understand correctly no, the container would not need An example is having a container sized according to various breakpoints. Ideally the canvas does not need to know those dimensions, it just fills the container regardless. I feel 'responsive' is a familiar enough terminology in the flex box and grid layout models for users to understand although it's not official |
Responsive in web world - associated with reaction of a style to a different resolutions and aspect ratios: mobile/tablet/desktop. |
Uh oh!
There was an error while loading. Please reload this page.
Problem
PlayCanvas currently supports:
•
FILLMODE_KEEP_ASPECT
andFILLMODE_FILL_WINDOW
: tied to the window size•
FILLMODE_NONE
: allows manual control over the canvas dimensionsHowever, a common use case - embedding a responsive canvas that fills its container (width: 100%; height: 100%) - requires manually tracking container size and managing updates with
FILLMODE_NONE.
This is unintuitive and boilerplate-heavy for something that should be simple.related - playcanvas/react#123
Proposal
Introduce a new fill mode:
FILLMODE_RESPONSIVE
- automatically sizes the canvas to fill its parent element using standard CSS dimensions.This would greatly simplify responsive layouts, especially for apps with embedded or resizable UIs.
Implementation
This could be implemented with a minimal change here, adding a clause to handle the new mode using:
The Graphics Device would naturally get the correct dimensions during update via
engine/src/framework/app-base.js
Lines 1311 to 1314 in 43d0ee2
/cc @willeastcott @mvaligursky @Maksims
The text was updated successfully, but these errors were encountered: