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

set Content Dialog not centered #1712

Closed
TommyCorr opened this issue Jan 26, 2021 · 18 comments
Closed

set Content Dialog not centered #1712

TommyCorr opened this issue Jan 26, 2021 · 18 comments

Comments

@TommyCorr
Copy link

When I open a Dialog with setContent(), it loads onto the bottom of the screen.
When i minimize and maximize the browser or change browser window width or height, the dialog centers properly.

Dialog 1
Dialog 2

Is there a way to redraw or refresh dialog position before opening? or is there a solution??

Thank you

@xscode-auto-reply
Copy link

Thanks for opening a new issue. The author has been notified and will review it as soon as possible.
For urgent issues and priority support, visit https://xscode.com/olton/Metro-UI-CSS or Patreon

@olton
Copy link
Owner

olton commented Jan 26, 2021

Please, create an example on codepen.io

@olton olton closed this as completed Jan 26, 2021
@TommyCorr
Copy link
Author

https://codepen.io/tommycorr/pen/bGwXYrz

Open the dialog, and then resize your browser window.

@olton olton reopened this Jan 26, 2021
@olton
Copy link
Owner

olton commented Jan 26, 2021

All ok for me

@olton
Copy link
Owner

olton commented Jan 26, 2021

You can use setPosition() API method to repositioning

@olton
Copy link
Owner

olton commented Jan 26, 2021

What version of Metro 4 you are use? Maybe you use not the latest version, and this version contains any bugs.

@TommyCorr
Copy link
Author

I'm using 4.4.3.

Do i use setPosition() before or after Metro.dialog.open('#dialog');?? and by default will it locate the dialog at the center??

@olton
Copy link
Owner

olton commented Jan 26, 2021

You can call setPosition after setContent. Also setPosition executing automatically when window is resized.

@TommyCorr
Copy link
Author

I added dialog.setPosition() after setContent and before open in the codepen i attached here, and no results.

@olton
Copy link
Owner

olton commented Jan 26, 2021

Check your browser console for errors

@TommyCorr
Copy link
Author

No errors :(

@TommyCorr
Copy link
Author

image

@olton
Copy link
Owner

olton commented Jan 26, 2021

Ok, I understand your problem. Maybe this is a bug in the dialog positioning procedure. I will study this question. Thank you for your feedback.

@olton olton added the bug label Jan 26, 2021
@TommyCorr
Copy link
Author

Thank you Olton, I'll be on the lookout

@olton
Copy link
Owner

olton commented Jan 27, 2021

Try this

    function OpenDialog() {
        var dialog = Metro.getPlugin('#IdDialog', 'dialog');
        dialog.setTitle('My Dialog Title');
        dialog.setContent(...);
        setTimeout(function(){
            dialog.open();
        }, 100);
    }

@olton olton closed this as completed Jan 27, 2021
@olton olton removed the bug label Jan 27, 2021
@TommyCorr
Copy link
Author

That did the trick, thank you Olton!

@olton
Copy link
Owner

olton commented Jan 27, 2021

Since the content for the dialog contains Metro components, which are built after adding them to the DOM, it takes some time to calculate the height correctly. For static content, you don't need to use setTimeout.

@TommyCorr
Copy link
Author

Noted, thank you for your support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants