Use a resize observer to center the popup after an image is loaded when polyfilled

b05d5e12fe2940b189812f6ceddea95d91c7ccec

QuantumEntangledAndy <sheepchaan@gmail.com>

Signed
1 files changed, +8 -0Showing whitespace changes
public/scripts/popup.js+8 -0
@@ -182,6 +182,14 @@ export class Popup {
182182 if (!this.dlg.showModal) {
183183 this.dlg.classList.add('poly_dialog');
184184 dialogPolyfill.registerDialog(this.dlg);
185+ // Force a vertical reposition after the content
186+ // (like crop image) has been set
187+ const resizeObserver = new ResizeObserver((entries) => {
188+ for (const entry of entries) {
189+ dialogPolyfill.reposition(entry.target);
190+ }
191+ });
192+ resizeObserver.observe(this.dlg);
185193 }
186194 this.body = this.dlg.querySelector('.popup-body');
187195 this.content = this.dlg.querySelector('.popup-content');