Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. /*Drag and Drop script for positioned divs and spans */
  2. var maxZdrag = document.getElementsByTagName("div").length;
  3. maxZdrag += document.getElementsByName("span").length;
  4. var dragElem = null;
  5. var dragging = false;
  6.  
  7.  
  8.  
  9. function setDrag(evt,elementID){
  10. dragElem = getObj(elementID);
  11. alert(dragElem);
  12. alert("SA");
  13. startDrag();
  14. }
  15.  
  16. function startDrag(){
  17. dragging = true;
  18. document.onmousemove=dragObj;
  19. document.onmouseup=dropObj;
  20. }
  21.  
  22. function dragObj(evt){
  23. if(window.event){evt = window.event;}
  24. if(evt){
  25. var x = evt.clientX - parseInt( getWidth(dragElem) / 2 );
  26. var y = evt.clientY - parseInt( getHeight(dragElem) / 2 );
  27. var z = maxZdrag++;
  28. shiftTo(dragElem,x,y,z);
  29. var pos = "drag coordinates are: " + x + ", " + y + ", " + z;
  30. alert(post);
  31. window.status=pos;
  32. }
  33. return false;
  34. }
  35.  
  36. function dropObj(){
  37. dragging = false;
  38. document.onmousemove=null;
  39. document.onmouseup = null;
  40. window.status="";
  41. }
  42. /* End drag and drop script */
  43. </script>
  44.  
  45. <div id="container">
  46. <p><img id="view-image" src="images/1.jpg" /></p>
  47. <ul id="thumbnails">
  48. <li class="pic1" onmousedown="setDrag(event,this);" onmouseup="checkdroploc()"><img src="images/1.jpg" /></li>
  49. <li class="pic2"><img src="images/2.jpg" /></li>
  50. <li class="pic3"><img src="images/3.jpg" /></li>
  51. <li class="pic4"><img src="images/4.jpg" /></li>
  52. <li class="pic5"><img src="images/5.jpg" /></li>
  53. <li class="pic6"><img src="images/6.jpg" /></li>
  54. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement