Closed curiousdannii closed 7 years ago
You're right, there's a hole in the rearrange logic there.
Is this the cause of https://github.com/erkyrath/glkote/issues/12 ? (I haven't investigated that yet, but I can hope...) EDIT: No, that's a vertical margin so it can't be the same thing.
This causes status-line layout problems in just about any Inform game with a right-hand status-line display, such as Advent.ulx. Shoulda noticed that months ago...
(Glkote puts a handler on the window size event, but CSS changes that affect #gameport also need to be detected.)
There's no DOM event for a size change on a div.
Polling is a possible answer, but I dislike it.
I see a frightening, but apparently reliable, method which involves making an invisible div and watching for scroll events... See https://github.com/marcj/css-element-queries/blob/master/src/ResizeSensor.js .
I had thought you could just directly issue a Glk event from the preferences window. If you'd prefer to keep a level of separation, why not trigger the browser resize event? $( window ).resize();
That would work but I'd prefer to handle the general case.
At another level of indirection you could wrap it all in an iframe, and change the iframe's size rather than #content.
Or you could probably use a MutationObserver. I think they're the official solution, but I have no idea how they work. And it may not work with styles, because that's an extension.
Another option: use a transition.
Unrelated: does Quixe currently throttle/debounce rearrange events?
Yes, there's a debounce timer in there. The arrange event isn't delivered until the browser size has settled down (0.2 seconds with no further change).
Glkote now has a resize sensor which covers this case.
When you change the margins from the preferences panel, rearrange events are not sent to the VM, leaving odd results like this:
The graphics window is set to take 50% of the width, and you can see from the sliver of black at the bottom that it is doing so. Changing the size of the window will issue a rearrange event and the game can sort itself out, but not all players will know they can do that.