diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2020-12-18 13:16:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-18 13:16:26 +0200 |
commit | c8e04dc5b30f8967c58df928872ca2e5e2be5c5b (patch) | |
tree | 6aae4f933e431470906b554053f21d070fe19b97 /server | |
parent | 49f70390add1655fc5eb846e7700d00cb57b5048 (diff) | |
download | vaadin-framework-c8e04dc5b30f8967c58df928872ca2e5e2be5c5b.tar.gz vaadin-framework-c8e04dc5b30f8967c58df928872ca2e5e2be5c5b.zip |
Fix to LayoutManager size calculations during transform. (#12138)
* Fix to LayoutManager size calculations during transform.
- ComputedStyle is slower but more reliable than using
getBoundingClientRect, which does not work as expected if a transform
has been applied to the element or one of its parents. This is a problem
e.g. with PopupView, where getBoundingClientRect will return too small
size (or even zero size) for all the popup contents while the opening
animation is active. ComputedStyle ignores the transform and returns the
expected value.
- The presence of the element in DOM must be checked before the size is
requested from ComputedStyle, if the element has disappeared from DOM
without a warning and calculation is attempted anyway, the browser gets
stuck.
- Possibility to configure LayoutManager to use the less reliable
calculations for applications where the slight performance difference is
more important than layout issues within elements that have transform
animations.
- Manual test, problem isn't reproducible by TestBench.
Fixes: #11187
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/UI.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/UI.java b/server/src/main/java/com/vaadin/ui/UI.java index 7430c04bb9..e291952f85 100644 --- a/server/src/main/java/com/vaadin/ui/UI.java +++ b/server/src/main/java/com/vaadin/ui/UI.java @@ -2022,6 +2022,40 @@ public abstract class UI extends AbstractSingleComponentContainer } /** + * Returns whether LayoutManager uses thorough size check that evaluates the + * presence of the element and uses calculated size, or defaults to a + * slightly faster check that can result in incorrect size information if + * the check is triggered while a transform animation is ongoing. This can + * happen e.g. when a PopupView is opened. + * <p> + * By default, the thorough size check is enabled. + * + * @return {@code true} if thorough size check enabled, {@code false} if not + * @since + */ + public boolean isUsingThoroughSizeCheck() { + return getState(false).thoroughSizeCheck; + } + + /** + * Set whether LayoutManager should use thorough size check that evaluates + * the presence of the element and uses calculated size, or default to a + * slightly faster check that can result in incorrect size information if + * the check is triggered while a transform animation is ongoing. This can + * happen e.g. when a PopupView is opened. + * <p> + * By default, the thorough size check is enabled. + * + * @param thoroughSizeCheck + * {@code true} if thorough size check enabled, {@code false} if + * not + * @since + */ + public void setUsingThoroughSizeCheck(boolean thoroughSizeCheck) { + getState().thoroughSizeCheck = thoroughSizeCheck; + } + + /** * Event which is fired when the ordering of the windows is updated. * <p> * The other way to listen window position for specific window is |