On Tuesday, March 11, 2014 6:42:16 PM UTC+1, Albert Riedinger wrote:
>
> I use Tobias Beers' fork of TiddlersBarPlugin[1] in my custom theme with 
> TiddlersBar fixed in left sidebar.
>

So your left sidebar is fixed too and it is always visible, when you sroll 
down?

 

> What I would like to achieve is that TiddlersBarPlugin remembers the 
> scroll position of tiddlers while switching between them[2]. I tried to 
> modify the code of TiddlersBarPlugin, but had to give up realizing that I 
> am only a JS beginner ;) My approach would be to save the horizontal and 
> vertical scroll positions in particular tiddler 
>
fields with code like this:
>

I wouldn't store those values with the tiddler, because you would get a new 
modified timestamp. If you want that, then it's ok. 
Do you really need the x position? In normal cases it is alway 0.

If only "y" is needed, you could create a "tbScrollPositions" tiddler with 
a lot of slices with the "tiddlername:y-value" in it. ... 
store.calcAllSlices("tbScrollPositions") should return all the tiddlers and 
there values. But you'd need to create a search function. so your approach 
is easier for the beginning.

story.displayTiddler = 
function(srcElement,tiddler,template,animate,unused,customFields,toggle){
    
story.coreDisplayTiddler(config.macros.tiddlersBar.tabsAnimationSource,tiddler,template,animate,unused,customFields,toggle);
    var title = (tiddler instanceof Tiddler)? tiddler.title : tiddler;  
    if (config.macros.tiddlersBar.isShown()) {
        story.forEachTiddler(function(t,e){
            if (t!=title) e.style.display="none";
            else {                     // <- a fast test
                e.style.display="";    // <- this will scroll 200 px down. 
So it should be the right place
                window.scrollTo(0, 200)// <- when you display the tiddler. 
            }
        })
        config.macros.tiddlersBar.currentTiddler=title;
    }
    var e=document.getElementById("tiddlersBar");
    if (e) config.macros.tiddlersBar.refresh(e,null);
}

Finding the place to save the value will be trickier. I'll post again :)

have fun!
mario

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to