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
Application and Renderer resize improvements #6415
Conversation
Had a play with a slight modified version of your fiddle: https://jsfiddle.net/w63ahoqd/ Can confirm that no matter how crazy I went on the window resizing, it occurs just ones per render |
Codecov Report
@@ Coverage Diff @@
## dev #6415 +/- ##
==========================================
+ Coverage 78.33% 78.54% +0.21%
==========================================
Files 57 57
Lines 2820 2825 +5
==========================================
+ Hits 2209 2219 +10
+ Misses 611 606 -5
Continue to review full report at Codecov.
|
Added a feature based on feedback from @GoodBoyDigital to set the amount of time to throttle instead of just using RAF. I agree this is more useful for producing more stable results, especially if you're doing something expensive on resize. const app = new Application({ resizeTo: window, resizeThrottle: 250 }); |
Just kidding, changed to 100ms |
Usually, people use |
The issue I have with this latest change is that if the screen keeps resizing, then nothing is ever updated. This has a 1 second resizeThrottle setting. Keep slowly resizing the window, and you'll notice that the resize event never kicks in, since a new window resize keeps resetting the timeout. This setting should be a throttle rather than a debounce, imo. |
But there not really cases when animated resize is required, if so, then app architecture apriory wrong. |
I think you're right @themoonrat. If I do this as only a throttle like I had before, users can still implement their own debounce with the |
@@ -9,9 +9,13 @@ import { IApplicationOptions } from './Application'; | |||
*/ | |||
export class ResizePlugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This plugin is hard to understand with all its static/this context mixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah these are static methods where the context is the Application instance. Loader plugins are similar.
I think the conversion to typescript actually made it less clear.
Not sure if it's the right thing for the plugin to be singleton-ish. |
It’s not really a singleton. No one calls this class directly. And it comes preinstalled, it’s mostly a code organization thing to keep from overloading Application. Could’ve been done a bunch of ways, but this is how it evolved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve it but with mark "burn it with fire as soon as we have special component dedicated to html part of renderer". Do not allow this code to become legacy stuff that goes from one version to another, this is piece belongs to a framework or animation widget or something like that.
I've been meaning to tackle this one for awhile, since no one seemed keen on adding the PR for it.
Fixes #6081
Added
resize
event to the Renderer. Called immediate after view is resized can be used for responsive layouts, or other resizing events.resizeTo
, this will prevent unnecessary extra event calls triggered by the window 'resize'.Example
https://jsfiddle.net/bigtimebuddy/u05c1s28/