closeButton.appendChild(span);
}
+ // Dialogs are positioned using `left: 50%` as a hack to
+ // force long softwrapping of text without causing other
+ // elements to be squished together. The actual value for
+ // `transform` must not use percent values, because this
+ // causes blurry text rendering in Chromium.
+ const resizeObserver = new ResizeObserver((entries) => {
+ if (dialog.getAttribute("aria-hidden") === "false") {
+ for (const entry of entries) {
+ const contentBoxSize: ResizeObserverSize = Array.isArray(entry.contentBoxSize)
+ ? entry.contentBoxSize[0]
+ : entry.contentBoxSize;
+
+ const offset = Math.floor(contentBoxSize.inlineSize / 2);
+ dialog.style.setProperty("transform", `translateX(-${offset}px)`);
+ }
+ }
+ });
+ resizeObserver.observe(dialog);
+
const contentContainer = document.createElement("div");
contentContainer.classList.add("dialogContent");
if (options.disableContentPadding) contentContainer.classList.add("dialogContentNoPadding");
span.className = "icon icon24 fa-times";
closeButton.appendChild(span);
}
+ // Dialogs are positioned using `left: 50%` as a hack to
+ // force long softwrapping of text without causing other
+ // elements to be squished together. The actual value for
+ // `transform` must not use percent values, because this
+ // causes blurry text rendering in Chromium.
+ const resizeObserver = new ResizeObserver((entries) => {
+ if (dialog.getAttribute("aria-hidden") === "false") {
+ for (const entry of entries) {
+ const contentBoxSize = Array.isArray(entry.contentBoxSize)
+ ? entry.contentBoxSize[0]
+ : entry.contentBoxSize;
+ const offset = Math.floor(contentBoxSize.inlineSize / 2);
+ dialog.style.setProperty("transform", `translateX(-${offset}px)`);
+ }
+ }
+ });
+ resizeObserver.observe(dialog);
const contentContainer = document.createElement("div");
contentContainer.classList.add("dialogContent");
if (options.disableContentPadding)
min-width: 500px;
position: absolute;
+ // This is required to prevent dialogs from becoming
+ // unncessarily wide by forcing text to wrap. We cannot
+ // use `transform` to offset this indentation, because
+ // this causes a blurry text rendering in Chromium.
+ // The offset is calculated using a `ResizeObserver`.
+ left: 50%;
+
&[aria-hidden="false"] {
animation: wcfDialog 0.3s;
animation-fill-mode: forwards;