-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Is there a way to store the actual scrollposition and restore this position later?
Example:
My cataloge.
- scroll down to the bottom an click to any picture [1]
- use the backbutton form the browser [2]
--> you will return to the overview, but the scroll position is on top
I want to store the scrollposition [1]
and restore it [2]
and [3]: Home/Startscreen button will clear the scroll-cache
Is there any way to do that?
I use Borderlayout. The content is in the center inside the html-component.
Any ideas?
/Robert
Hey Robert,
This is currently not implemented yet, what I have done is added it to the feature requests on sourceforge. You can find it here!
Thanks,
Tim
Hi Tim.
Thanks for your answer and featurerequest. I've done some tests with clientcoding (scrollTop, srollLeft).
I think, i will migrate to ZK5 first - client coding seems to be smarter there :-)
However, actually my cataloge do not work with ZK5RC: no tree and no error to see :-(
/Robert
Here's a technique I used that might work for you. Note: I have only tested this in ZK 3.6.2, I don't think it works in ZK 5. In my case I had a tree object. Clicking on a treerow was supposed to update a window sitting next to the tree. Without this technique, if the tree was scrolled down a bit then when the window updated it pushed the scroll bar back to the top...very annoying.
So instead of writing a normal onclick event listener to do my window update, for each treerow (tr) I did
String uuid=tr.getTree().getUuid()+"!body"; tr.setAction( "onclick: var t=document.getElementById('"+uuid+"');"+ "comm.sendUser('"+tr.getUuid()+"', t.id, t.scrollTop);" );
and then I wrote an onuser EventListener, and applied it to each treerow:
private static EventListener onUserListener = new EventListener () { public void onEvent (Event ev) throws Exception { String []data=(String[]) ev.getData(); String tableBodyId=data[0]; String scrollTop=data[1]; if (new Integer(scrollTop).intValue()>0) // restore original scrollTop value Clients.evalJavaScript("var t=document.getElementById('"+tableBodyId+"');t.scrollTop="+scrollTop+";"); } };
The key was knowing which uuid value to use in order to grab the scrollTop value; I figured it out by using Firebug and a bit of trial and error testing. Tested ok with FF 3.5, and IE 6, 7, 8. Did not test any others.
Big thanks Elen,
i'll check this out today.
/Robert
Asked: 2009-11-03 08:30:28 +0800
Seen: 598 times
Last updated: Nov 10 '09