Determining viewport (not screen) size

Hi folks,

Is there a way to determine the viewport size? We have some screen size tiddlers in $:/info/, but I’d like to know the window / viewport size. I’m hoping to conditionalize some tiddlers to display differently at a very specific size.

I suppose I could use CSS, but I’d love a TW native solution.

see https://tiddlytools.com/#TiddlyTools%2FStartup%2FWindowSize.js

This small “startup” JS module gets the current browser window size (actually the “innerWidth” or “clientWidth” and the “innerHeight” or “clientHeight”) and saves them in $:/info/browser/window/width and $:/info/browser/window/height. It also sets up a listener for “resize” events to automatically update the $:/info tiddlers whenever the window is resized by user interactions.

enjoy,
-e

Wow, this works great! I made a small modification to not dirty the tiddler store on change (updating the path to be $:/temp/info...), but this is working great. Thanks, Eric!

You can prevent changes to the $:/info tiddlers from marking the file as “dirty” by adding

-[prefix[$:/info]]

to the filter definition contained in $:/config/SaverFilter.

In addition, you can prevent the $:/info tiddlers from actually being saved in the file by creating a tiddler (e.g., “PublishFilter”), tagged with $:/tags/Macro containing the following macro definition:

\define publishFilter()
-[prefix[$:/info]]
\end

enjoy,
-e