Draggable stickywin that remembers its position on the screen

0 views
Skip to first unread message

Alessandro Astarita

unread,
Nov 4, 2009, 5:54:15 AM11/4/09
to Clientcide
Hi to all.

Is it possibile to force a draggable stickywin to remember its
position on the screen? I would like to open a stickywin, drag it
somewhere, close it, and then, once reopened, see it in the dragged
position.

Is it possible?

Thank you

Alex

Philip Thompson

unread,
Nov 4, 2009, 10:03:38 AM11/4/09
to clien...@googlegroups.com

You would have to store the coordinates somewhere and then look up
those coordinates when opening the window. A database comes to mind
first. Maybe a cookie?

Hope that helps.
~Philip

Aaron Newton

unread,
Nov 4, 2009, 12:40:19 PM11/4/09
to clien...@googlegroups.com
It's possible that the current codebase (2.1.0) doesn't work this way, but my current tests of 2.2.0 (due out in the next week or so) shows that this is how it works. If I drag a window somewhere, hide it, then show it again, it's where I left it.

Philip Thompson

unread,
Nov 4, 2009, 3:38:26 PM11/4/09
to clien...@googlegroups.com
Is this done with a cookie? Or just stored in a JS variable?

~Phil

Aaron Newton

unread,
Nov 4, 2009, 4:06:48 PM11/4/09
to clien...@googlegroups.com
no, when you drag an element it's position is set in its css text via element.setStyle. I.e. you drag 5 pixels to the left, and the 'left' style property is incremented 5px.

Now you hide the window and that sets its display style to "none". Showing the window again just sets the display property back to "block", but the position properties aren't altered.

Based on your questions I'm betting you're creating a new StickyWin every time the user wants to show something. For instance, lets say you have a date picker next to an input appear when the user clicks into the input. The user drags the picker to the side, then closes it. Later, they come back to that input and click inside it. The date picker shows up again, but now it's reset to be next to the input.

This will happen if you have your logic like this:

input.addEvent('focus', function(){
  new StickyWin(...);
});

Instead, do this:

var inputSticky = new StickyWin(...); //set showNow option to false so it's hidden
input.addEvent('focus', function(){
  inputSticky.show();
});
//later the user closes the window, then focuses the input again, and it just displays the popup again, unmoved.

Alessandro Astarita

unread,
Nov 6, 2009, 5:28:06 AM11/6/09
to Clientcide
Thank you so much. I used the show() method, and it works correctly.

Alex

Alessandro Astarita

unread,
Nov 6, 2009, 5:28:16 AM11/6/09
to Clientcide
Thank you so much. I used the show() method, and it works correctly.

Alex

On 4 Nov, 22:06, Aaron Newton <aa...@iminta.com> wrote:
Reply all
Reply to author
Forward
0 new messages