1.  
  2. var thingToDrag = document.getElementById("ThingToDrag");
  3. ...
  4. var ddThingToDrag = new YAHOO.util.DD(thingToDrag);
  5. ...
  6. ddThingToDrag.onDrag = function(e) {
  7. topMarker.style.display = "block";
  8. leftMarker.style.display = "block";
  9.  
  10. var left = parseInt(thingToDrag.style.left) + "px";
  11. var top = parseInt(thingToDrag.style.top) + "px";
  12. thingToDrag.innerHTML = left + ", " + top;
  13. topMarker.style.top = topMarker.innerHTML = top;
  14. leftMarker.style.left = leftMarker.innerHTML = left;
  15. }
  16. ddThingToDrag.startDrag = function(x,y) {
  17. var dragEl = this.getDragEl();
  18. topMarker.style.width = screen.width + "px";
  19. leftMarker.style.height = screen.height + "px";
  20. topMarker.style.display = "block";
  21. leftMarker.style.display = "block";
  22. to.push({left: YAHOO.util.Dom.getX(dragEl), top: YAHOO.util.Dom.getY(dragEl)});
  23. }
  24. ...
  25. ddThingToDrag.endDrag = function(e) {
  26. if (this.getDragEl) {
  27. var dragEl = this.getDragEl();
  28. from.push({left: YAHOO.util.Dom.getX(dragEl), top: YAHOO.util.Dom.getY(dragEl)});
  29. }
  30. topMarker.style.display = "none";
  31. leftMarker.style.display = "none";
  32. if (to.length > 0) {
  33. undoBtn.style.display = "block";
  34. } else {
  35. undoBtn.style.display = "none";
  36. }
  37. if (this instanceof YAHOO.util.Motion) {
  38. this.onComplete.unsubscribe(handleComplete);
  39. this.onTween.unsubscribe(handleTween);
  40. }
  41. }
  42.  
  43.