Skip to content
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

Allow dialog centering after width/height changes #601

Open
mvysny opened this issue Nov 11, 2020 · 1 comment
Open

Allow dialog centering after width/height changes #601

mvysny opened this issue Nov 11, 2020 · 1 comment
Labels
enhancement New feature or request vaadin-dialog

Comments

@mvysny
Copy link
Member

mvysny commented Nov 11, 2020

I'd like to implement a "maximize" button which will set the 100vw/100vh size to the dialog. That works, however the dialog stays at its current position, which leads to parts of dialog not visible. It would be good if the "maximize" button could also call dialog.center(); to re-center the dialog, in order to show it in its entirety.

@mvysny
Copy link
Member Author

mvysny commented Nov 11, 2020

The trick is to clear the styles of the dialog overlay. The following Java snippet works:

    private void center(Dialog dialog) {
        final ArrayList<String> styles = new ArrayList<>();
        if (dialog.getWidth() != null) {
            styles.add("width: " + dialog.getWidth());
        }
        if (dialog.getHeight() != null) {
            styles.add("height: " + dialog.getHeight());
        }
        dialog.getElement().executeJs("this.$.overlay.$.overlay.style = '" + String.join(";", styles) + "';");
    }

@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-dialog May 19, 2021
@vaadin-bot vaadin-bot added enhancement New feature or request vaadin-dialog labels May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vaadin-dialog
Projects
None yet
Development

No branches or pull requests

2 participants