[tw5] Any way to force a refresh upon window events?

37 views
Skip to first unread message

AdamS

unread,
Dec 6, 2018, 4:20:37 PM12/6/18
to TiddlyWikiDev
I'm trying to build a widget that fills a state tiddler with information about the window and document dimensions. I'm wanting to refresh the widget whenever the window is resized or document offsetHeight changes, rather than whenever a tiddler is changed. Anyone know of any way to do that?

Jeremy Ruston

unread,
Dec 6, 2018, 4:32:04 PM12/6/18
to TiddlyWikiDev
Hi Adam

I'm trying to build a widget that fills a state tiddler with information about the window and document dimensions. I'm wanting to refresh the widget whenever the window is resized or document offsetHeight changes, rather than whenever a tiddler is changed. Anyone know of any way to do that?

You can construct a widget that refreshes whenever the viewport size changes using the DynaView plugin. It maintains a state tiddler $:/state/DynaView/ViewportDimensions/ResizeCount that contains a count that is incremented at each refresh. Widgets can check for modifications to that tiddler in their refresh method. For example:

if(changedTiddlers["$:/state/DynaView/ViewportDimensions/ResizeCount"]) {
foo()
}

The DynaView plugin also saves the viewport size in the tiddlers $:/state/DynaView/ViewportDimensions/Width and $:/state/DynaView/ViewportDimensions/Height, although it doesn’t track changes to the rendered document size.

The DynaView plugin can be installed from the official plugin library, and you can try it out here:


Best wishes

Jeremy.



--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/0fc3e356-e1a3-4272-a367-36ff6fc1e1af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

AdamS

unread,
Dec 6, 2018, 4:35:09 PM12/6/18
to TiddlyWikiDev
Thank you, Jeremy!

That's good news. Thanks for saving me from trying to reinvent the wheel!

Best regards,

Adam
Reply all
Reply to author
Forward
0 new messages