Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Draggable Layers?

    I'm trying to emulate a windows desktop environment on a web page, and i'm a little bit stuck.

    I want to be able to have draggable "psuedo-window" layers.

    I've been able to find a few draggable layer scripts and draggable image scripts but havent come up with the right modifications for what i need.

    I want to be able to click and drag a certain element contained within a layer, which will then drag the entire layer. This, to emulate the draggability property of the title bar of a 'windows' window.

    Can anyone help me out, please?

    -Shecky

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Is this any good?



    <SCRIPT language=JavaScript1.2>
    <!--
    moving2 = false;

    function Dragnow2(){
    if(event.srcElement.className!="dragme") return; // Only move "dragme" objects
    moving2=true;
    obj=event.srcElement;
    X_offset=event.clientX-event.srcElement.style.pixelLeft; // differnce between the obj pos and cursor pos X
    Y_offset=event.clientY-event.srcElement.style.pixelTop; // differnce between the obj pos and cursor pos Y
    document.onmousemove=Moveto2;
    }

    function Moveto2(){
    if(!moving2) return true;
    if(event.button!=1) return true;
    obj.style.pixelLeft=event.clientX-X_offset; // new position X
    obj.style.pixelTop=event.clientY-Y_offset; // new position Y
    return false;
    }

    document.onmouseup=new Function("moving2=false");
    document.onmousedown=Dragnow2;
    // -->
    </SCRIPT>

    <DIV class="dragme" style="position:absolute;top:0;left:0;cursor:hand;border:2 solid red">Hello World</DIV>

    <DIV class="dragme" style="position:absolute;top:100;left:0;cursor:hand;border:2 solid blue">Hello World</DIV>



  • #3
    Regular Coder
    Join Date
    Dec 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    not exactly

    Not exactly what i'm looking for. I could probably figure it out from that code if i wasnt retarded, but this is what i need.

    ______________
    |______1______|
    |.....................|
    |.....................|
    |..........2.........|
    |.....................|
    |_____________|

    1 & 2 = the entire layer
    1 = object, image, or SOMETHING on the layer
    2 = the rest of the layer

    By clicking and dragging '1' I want to be able to drag the entire layer (1 and 2)

    Clicking and dragging should not work in the '2' area.

    Like how the window yer reading this in works.
    Last edited by Shecky; 12-31-2002 at 01:37 PM.

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Got ya ...

    Here's one I put on the shelf a while back.

    Still needs a bit of attention maybe but see if it will do you.
    Attached Files Attached Files

  • #5
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Something I had done a long time ago as a proof of concept. I don't think the binding for Mozilla works anymore, but it shouldn't be too hard to update to post-1.0 XBL...
    Attached Files Attached Files

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Depends on the time of year
    Posts
    478
    Thanks
    0
    Thanked 0 Times in 0 Posts
    has exactly the program you looking for..

    http://www.dhtmlcentral.com/

    Duniyadnd

  • #7
    Regular Coder
    Join Date
    Dec 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile i love you

    Thanks everyone! I love you like a pregnant woman loves pickles in her icecream!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •