From 9258cecc73e8b29aae58c5cf8a1281255d4c54f8 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 23 May 2024 12:16:54 +0200 Subject: [PATCH] service2.js: Reintroduce window resize event listening This is an emergency solution to track host element position changing. --- service2.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/service2.js b/service2.js index b87191c..79bc71e 100644 --- a/service2.js +++ b/service2.js @@ -9,6 +9,14 @@ */ let besServices = [] +// TODO: Window resize may cause host element(s) to move. That needs correction panel and status icon +// repositioning. Also, should any parent element of our service host element move, we should reposition +// correction panel and status icon. How to do this? Alas there is no PlacementObserver to monitor host +// element movements. +window.addEventListener('resize', () => + besServices.forEach(service => service.onReposition()) +) + /************************************************************************* * * Base class for all grammar-checking services @@ -135,6 +143,14 @@ class BesService { }, 500) } + /** + * Called to report repositioning + */ + onReposition() { + this.setCorrectionPanelSize() + this.setStatusDivPosition() + } + /** * Called to report resizing */