-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
FR: keep vertical centering updated #183
Comments
For now I've found a workaround: util/dialog.ts import {DOM} from 'aurelia-framework';
export function vCenterWithBodyObserver(modalContainer: HTMLElement) {
const wrapper = <HTMLElement>modalContainer.children[0];
recenter(wrapper);
let observer = new MutationObserver(() => recenter(wrapper));
observer.observe(modalContainer.querySelector("ai-dialog-body"), { attributes: true, childList: true });
}
function recenter(element: HTMLElement) {
const vh = Math.max((<HTMLElement>DOM.querySelectorAll('html')[0]).clientHeight, window.innerHeight || 0);
element.style.marginTop = Math.max(((vh - element.offsetHeight) / 2), 30) + 'px';
} my-dialog-opener.ts import {vCenterWithBodyObserver} from "util/dialog";
export MyDialogOpener {
// ...
openDialog() {
this.dialogService.open({
model: this.getDialogModel(),
viewModel: this.getDialogViewModel(),
position: vCenterWithBodyObserver
});
}
} This re-centers after every change to the attributes or direct children of <ai-dialog-body data-subitems-fetched="${fetcher.done}">
<ul class="child">
<li class="descendant" repeat.for="subitem of fetcher.subitems">${subitem}</li>
</ul>
</ai-dialog-body> Not the most elegant solution, but it'll do the job for now. P.S.: adding |
@jedd-ahyoung Ping. |
For me the simplest workaround is to use a couple of css rules:
|
@lulumetro nice trick, i've tested it and works very well! |
I've also noticed another difference between my own solution and the one implemented in aurelia-dialog: I'm placing the dialog by only adjusting |
@lulumetro Works great in evergreen browsers, but in Internet Explorer (even 11) it looks funky. |
I found something configuring the plugin in my main.js:
Hope it will help :) |
I found with the main.js config above, the dialogs were right-aligned in IE, so I added some -ms-prefixed css properties to get it working:
|
I'm submitting a feature request
1.0.0-beta.1.1.0
Please tell us about your environment:
Linux (Ubuntu 16.04)
6.2.2
3.9.5
JSPM 0.16.29
Chrome 51
TypeScript 1.8.9
Current behavior:
The dialog is vertically centered the moment it opens. The dialog top stays the same distance from the top of the screen after this. If bindings change and new content is added, or existing content is removed, the height of the dialog changes, but the distance from the top of the screen stays the same. If the dialog height increases, a scrollbar may appear and the user can scroll down to bring the dialog closer to the top of the screen.
Expected/desired behavior:
The ideal case would be that every time bindings change and content is re-rendered, the dialog is automatically re-aligned. However, this may be annoying if it happens too frequently, so this behavior should be influencable through dialog settings. An acceptable substitute is if the dialog's ViewModel can manually have the dialog re-aligned at pre-determined events, like when new content becomes available.
As it is, tall content displayed in a dialog after it opens causes vertical alignment to go awry. For example, I'm working on a wizard to restore backups. The backups are loaded only when the dialog is opened. When rendered, it looks like this (background blacked out as it is not relevant to this):
The text was updated successfully, but these errors were encountered: