diff options
author | Henri Sara <henri.sara@gmail.com> | 2017-09-26 10:28:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-26 10:28:14 +0300 |
commit | 4d6cb7b107040ec9aedf9b73725675309a1c5729 (patch) | |
tree | b9ed625629cf2b247ee8758ac763721da62610bc /client | |
parent | e0b661fae56d52f36731945396b6b07c5c40a747 (diff) | |
download | vaadin-framework-4d6cb7b107040ec9aedf9b73725675309a1c5729.tar.gz vaadin-framework-4d6cb7b107040ec9aedf9b73725675309a1c5729.zip |
Relayout GridLayout when font loading completes (#10077)
If a GridLayout is used and font loading is not complete, force another layout after all fonts are loaded.
Fixes #9921
Fixes #8207
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java b/client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java index 3113183e3e..6749d14b10 100644 --- a/client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java @@ -41,6 +41,8 @@ import com.vaadin.ui.GridLayout; public class GridLayoutConnector extends AbstractComponentContainerConnector implements DirectionalManagedLayout { + private static boolean fontLoadingCallbackRegistered = false; + private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( this) { @@ -64,8 +66,26 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector getLayoutManager().registerDependency(this, getWidget().spacingMeasureElement); + + if (!fontLoadingCallbackRegistered) { + fontLoadingCallbackRegistered = true; + registerFontLoadedCallback(); + } } + private static native void registerFontLoadedCallback() + /*-{ + try { + if ($doc.fonts && $doc.fonts.status == 'loading') { + $doc.fonts.ready.then(function () { + $wnd.vaadin.forceLayout(); + }); + } + } catch(err) { + // fonts ready promise not supported by the browser + } + }-*/; + @Override public void onUnregister() { VGridLayout layout = getWidget(); @@ -151,7 +171,6 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector cell.setComponent(componentConnector, getChildComponents()); } - } private void initSize() { |