PDA

View Full Version : How do I make "draggable" layers "jump" back to original position?


Deanna475
03-13-2003, 02:24 AM
I'm currently working on a project I call a Page Colourizer and involves 8 "popup" windows or panels, as I call them. Each panel is draggable, minimizable [using onoffdisplay()] and can be closed on the click of a button. When the user opens the page, all of the panels are lined up in a neat and organized fashion. As the user begins to use the Page Colourizer, he/she will more than likely start moving panels all over the screen. At some point, they may wish to have the panels line up again, as they were when they first opened the page.

Here's the question: Using a double click action in the title /caption bar forming part of each panel, how do I code it so that the panel will "jump" back to it's original position?

A working beta version of Page Colourizer can be found here:

http://www.theinspirationgallery.com/neo/page_colourizer.htm

Thanks in advance to anyone who can steer me in the right direction.

justame
03-13-2003, 02:35 AM
dea...
just a hugs® n' hey theres...:O))) ...n' did ya just a think® of mayyybe having your just a ction® aka...reset...sooo code it to do the sameee thing when the page had just a loaded®??? ummm.../me is just a guessing® thattt somewhere in your instructions??? ya just a gots® ...
"quote...lined up in a neat and organized fashion...endquote"

just a suggestion® n' 'excuse' to say hi n' good to see ya...:O))) n' trusting things are improving healthwise in your family betterer thannn here...

Graeme Hackston
03-13-2003, 02:37 AM
Get their offsetTop and offsetLeft onload, store x and y in an array or as variables. Ondoubleclick fire a function that returns them

Deanna475
03-13-2003, 02:48 AM
Justame!!! Hello to you as well. Ummm, things in the family are not so good health-wise. Sorry to hear your family's health problems continue, as well. I'm "playing" with this interactive web project to take my mind off things. As for your "reload/refresh" idea, that would work but then the user would lose all of their settings in the sample page they were creating. If you take a look at the actual page, you'll see what I mean. *S*

And hello to Graeme!! Thank you for your input. I can modify existing scripts (with the author's permission, of course *S* which is what this project has basically come down to) but I can't write one from scratch, although I catch the jist of what you are suggesting. Unfortunately, unless someone spells it out for me, I'm kinda hopeless. :(

Graeme Hackston
03-13-2003, 03:00 AM
Hi Deanna, sorry but that's quite a task. What needs to be done is simple. Injecting it in all that JS would be simple if I knew it. You might try asking the author.

Sorry I couldn't be more help.

Deanna475
03-13-2003, 03:09 AM
Hi again G. I know what you mean!! All that JS!! It's gotta be a mile long on the page!! I would have asked the author but he is away for awhile and I was kinda hoping to surprise him with this new "little" addition to his script. I'm running the whole project by him for his final blessing before I make it available to the masses. Maybe it will have to wait .......

Vladdy
03-13-2003, 04:00 AM
FYI: your page fails miserably in gecko browsers :( :(

Deanna475
03-13-2003, 04:13 AM
Yeah, I know. It's only coded for IE5+. Did I forget to mention that? :eek: If this project ever goes "live", that fact will be made known at the very top of the page where all that empty space is.

Vladdy
03-13-2003, 11:52 AM
Why don't code it to the standards :confused: :confused:

GoHF
03-13-2003, 02:05 PM
Standards are boring.
Anyway, here is a code that might work.
Add this to the big bad <script> on your page, and then add the "saveInitialPositions()" to you <body> onload.


var popWindows = new Array();

function resetPosition(){
popwinClass = 'popwin';
popwin = event.srcElement;

while (popwin.parentElement && (popwin.className != popwinClass))
popwin = popwin.parentElement;
if (popwin.className != popwinClass) return;

popwin.style.left = parseInt(popWindows[popwin.id][0]);
popwin.style.top = parseInt(popWindows[popwin.id][1]);
}

function saveInitialPositions(){
popwinClass = 'popwin';
popwinArray = window.document.getElementsByTagName('DIV');
tmp = 0;
for (i=0; i<popwinArray.length; i++)
if ((popwin = popwinArray[i]).className == popwinClass){
popWindows[popwin.id] = [ popwin.offsetLeft, popwin.offsetTop];
popwin.ondoubleclick = resetPosition;
tmp++
}
}

Deanna475
03-14-2003, 06:55 AM
Hi GoHF and thank you for your assistance. There are two places where your code snippet could be included: (1) in the <head> script which we call the "big bad script"; or (2) at the very bottom of the HTML document itself where there is a script pertaining to the drag+drop, active/inactive colour functionality and initialization of the popups.

I placed your code at the bottom of each of these scripts and made sure to include the onload command but, alas, it didn't do anything! It doesn't cause any JS error messages, nor does it interfere with the overall functionality of the page, but it doesn't make the popups reposition themselves on a double click.

If you are so inclined or have the time or interest to take another crack at it, I won't stop you. ;) If not, then don't lose any sleep over it -- my IE5+ only end users can do without. As for me, I'll be emotionally scarred, but somehow I'll manage to carry on ......... :D

Deanna475
03-14-2003, 09:11 PM
UPDATE!! To GoHF and anyone else who reads this thread, I have established contact again with the author of the "big bad script" and he is going to work on some modifications to it this weekend, including making the popup windows jump back to their original position on a double click.

I thank those of you, especially GoHF, for your input and interest in my dilemma. With the author excited about the changes I made to his script and his eagerness to help me work out the "bugs", this IE only *S* interactive page colourizer will surely get off the ground now and I will post a link to it on my web site when it is ready for the web world to beta test thoroughly for me!

Again, thanks guys. I owe you one!! :thumbsup:

justame
03-15-2003, 03:35 PM
dea...
just a great® to hear thattt things look like theyre just a goingtobeworkingsoon® on the ol' script end of things...:O)))
n' just a looking® forward to reading thattt alll has been just a scripted/solved® :O)))