Make infomechanism refresh without reload?

If you turn a tablet screen sidewise, the width of the browser window changes. But, apparently, the number provided by the infomechanism stays the same. Is there some way to “nudge” the mechanism so that it will re-evaluate at least the screen width? This would be useful not only for people on tablets, but for people using multiple monitors, switching a TW from screen to screen.

Thanks!

1 Like

The TWCore InfoMechanism provides $:/info/browser/screen/width and $:/info/browser/screen/height values (in pixels) for the device screen dimensions, which are always the same and, as you’ve noted, do not respond to changes in screen orientation.

However, the TWCore’s InfoMechanism does not currently provide any values for the browser client window dimensions, which might fit the device screen dimensions when the window is maximized, but can also be adjusted to any size, typically by dragging the edges of the browser window.

To address this, I’ve written a TiddlyTools startup module (JS code) that automatically creates two new tiddlers: $:/info/browser/window/width and $:/info/browser/window/height that contain the current browser client window dimensions (in pixels). The startup module also adds an event listener for “window resize events” to automatically update the $:/info/browser/window/width and $:/info/browser/window/height tiddlers whenever the browser window is resized (which includes events caused by changing the tablet orientation).

To install this startup module, just go to https://tiddlytools.com/#TiddlyTools%2FStartup%2FWindowSize.js and drag-and-drop the tiddler title onto your TiddlyWiki to import it. Then save-and-reload for the code to take effect.

enjoy,
-e

5 Likes