Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Drag & resize??

  1. #1
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Drag & resize??

    Can anyone guide me how to convert this drag script:

    Code:
    ...
    <script type="text/javascript">
    var ie = document.all;
    var ns = document.getElementById && !ie;
    
    var isdrag = false;
    var x,y;
    var dobj;
    
    function mousemove(e){
    if(isdrag){
    dobj.style.left = ns ? tx + e.clientX - x : tx + event.clientX - x;
    dobj.style.top = ns ? ty + e.clientY - y : tx + event.clientY - y;
    return false;
    }
    }
    
    functions startDrag(e){
    var fobj = ns ? e.target : event.srcElement;
    var topelement = ns ? "HTML" : "BODY";
    
    if(fobj.tagName != topelement && fobj.className != "drag"){
    fobj = ns ? fobj.parentNode : fobj.parentElement;
    }
    
    if(fobj.className == "drag"){
    isdrag = true;
    dobj = fobj;
    tx = parseInt(dobj.style.left + 0);
    ty = parseInt(dobj.style.top + 0);
    x = ns ? e.clientX : event.clientX;
    y = ns ? e.clientY : event.clientY;
    document.onmousemove = mousemove;
    return false;
    }
    }
    document.onmousedown = startDrag;
    document.onmouseup = function(){isdrag=false;}
    </script>
    <body>
    <div style="height:100px;width:100px;background-color:red;position:relative;" class="drag"></div>
    ...
    Into a drag-resize script?? Any help would be greatly appereciated.

    And yes, can anyone also tell me how to detect if the element which is to be dragged is in a certain position in the screen?? Something which might help in making a drag-drop shopping cart??

    Thank you again.

  2. #2
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Please don't mind me. I am just posting a lot of nonsense.

  3. #3
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, but I already have them. I need a way how to make it with my kind of code. Not just download a library and use it. I need to know it myself(What if I need to make it in some other computer and there is a condition where there is no internet?? I cannot rely on the libraries). But thanks anyways.

  4. #4
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I need a way how to make it with my kind of code. Not just download a library and use it. I need to know it myself
    i so know what ur saying, man
    Please don't mind me. I am just posting a lot of nonsense.

  5. #5
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jr_yeo
    i so know what ur saying, man
    Thanks for understanding. I was at last able to memorize that whole drag script(and understand it as well).

    But anyways thanks for your help.

  6. #6
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks for your help.
    ur welcome
    Please don't mind me. I am just posting a lot of nonsense.

  7. #7
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Anyone who has the solution of my problem??

  8. #8
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Anyone who knows a fix for this??

  9. #9
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh Please!!! Anyone help me.

  10. #10
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Quote Originally Posted by shachi
    Can anyone guide me how to convert this drag script:

    Code:
    ...
    <script type="text/javascript">
    var ie = document.all;
    var ns = document.getElementById && !ie;
    
    var isdrag = false;
    var x,y;
    var dobj;
    
    function mousemove(e){
    if(isdrag){
    dobj.style.left = ns ? tx + e.clientX - x : tx + event.clientX - x;
    dobj.style.top = ns ? ty + e.clientY - y : tx + event.clientY - y;
    return false;
    }
    }
    
    functions startDrag(e){
    var fobj = ns ? e.target : event.srcElement;
    var topelement = ns ? "HTML" : "BODY";
    
    if(fobj.tagName != topelement && fobj.className != "drag"){
    fobj = ns ? fobj.parentNode : fobj.parentElement;
    }
    
    if(fobj.className == "drag"){
    isdrag = true;
    dobj = fobj;
    tx = parseInt(dobj.style.left + 0);
    ty = parseInt(dobj.style.top + 0);
    x = ns ? e.clientX : event.clientX;
    y = ns ? e.clientY : event.clientY;
    document.onmousemove = mousemove;
    return false;
    }
    }
    document.onmousedown = startDrag;
    document.onmouseup = function(){isdrag=false;}
    </script>
    <body>
    <div style="height:100px;width:100px;background-color:red;position:relative;" class="drag"></div>
    ...
    Into a drag-resize script?? Any help would be greatly appereciated.

    And yes, can anyone also tell me how to detect if the element which is to be dragged is in a certain position in the screen?? Something which might help in making a drag-drop shopping cart??

    Thank you again.
    There's something wrong with the script....

    "Expected ; on line 23"
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

Bookmarks

Posting Permissions

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