[IDEA] variable for "is in viewport"

The following request is intended to be a github “feature request” but, as you know, such proposals should be actionable, so I first want to bounce it here.


Is your feature request related to a problem? Please describe.
Over the years, I’ve consistently hit situations where I want to programmatically know if someting - a tiddler or something within the tiddler body - is in the viewport or not.

Some use cases
A basic application would be an indicator in the sidebar lists to indicate which title is currently seen in viewport (this is sometimes hard to discern - like with browser tabs, I keep many tiddlers open at the same time. I understand different personality types behave differently in this regard.)

A more ambitious application would be a kodemo type storyview/layout.

A third, and more general example, would be a kind of lazy-loading that triggers from scrolling to a tiddler, or to show some css effect from its start state - this is very common when scrolling web pages but unclear how to achieve with TW.

A general enough implementation could perhaps even be used for “synched editor+ouput scrolling” seen on some dev sites. Considering how TW widget calls and their output often take up totally differently sized vertical real estate, this would be particularly useful in the editor preview display.

Describe the solution you’d like
A dynamic variable, comparable to currentTiddler but with the title of the single tiddler or other element that occupies a certain y-position in the viewport (e.g the top-of-scroll position).

…And/or a widget(?) that triggers when scrolled into view, so that the user can position and encapsulate stuff at arbritrary positions within the tiddler body.

Describe alternatives you’ve considered
@felixhayashi created the HotZone plugin. While HotZone does feature the dynamic variable mentioned above, it only does so for tiddler titles, not arbitrary elements within the body. And, overall, the requested functionality is IMO general enough to be a native feature in TW. Especially as a plugin creator, it is not practical to have to rely on and refer to, other plugins when creating new public plugins.

@twMat just a quick check you have looked at the core plugin Dynaview? Sounds similar if not containing some of the technology you need.

Yeah, thanks. While it admittedly was quite long ago that I fiddled with it, it only somewhat overlaps what I’m requesting and, on the other hand, it also adds a LOT that I’m not requesting. IMO, to be able to see what is inside viewport is both general enough and useful enough to be included in native TW.

(Also, as I peek at the plugins “readme” I note that “This is really just a proof of concept [snip]”)

1 Like

That documentation needs changing! I’ve used Dynaview in many projects, and consider it quite robust. It directly implements all of the use cases that you list.

I should have said to feel free to respond here with any questions as you get to grips with it.

@twMat you idea of a simple variable for this would be quite powerful,

I have a solution I call “focused tiddler” which goes a long way towards this kind of handling, when you navigate to a tiddler it gains focus, then if you scroll down the story you can set a new focused tiddler or return to the last one. It helps find or return to “your place” in the story.

  • If the variable you propose were available we could maintain information about the current tiddler that is visualy focused along side that which was intentionaly focused and provide real help navigating tiddlers we are using.
  • When you can access such “analytics” about tiddlers the user is working with you can start to add real and almost automatic tools that “understand what the user is doing, and offer help”.