TestEvent_MouseCapture.html 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  5. <title>Project1</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <style>
  8. div {
  9. padding: 5px;
  10. border: 5px solid blue;
  11. margin: 4px;
  12. }
  13. #wing{
  14. width: 200px;
  15. height: 50px;
  16. overflow-x: scroll;
  17. overflow-y: visible;
  18. position: relative;
  19. }
  20. </style
  21. </head>
  22. <body>
  23. <script>
  24. console.log('AAA1');
  25. function Show(){
  26. var El = document.getElementById('wing');
  27. console.log('Client: l='+El.clientLeft+' t='+El.clientTop+' w='+El.clientWidth+' h='+El.clientHeight+' Scroll: Left='+El.scrollLeft+' Width='+El.scrollWidth+' Top='+El.scrollTop+' Height='+El.scrollHeight);
  28. }
  29. window.addEventListener("load", (event) => {
  30. var El = document.getElementById('feather');
  31. El.addEventListener('mousemove',function (e){
  32. console.log('Feather mousemove client='+e.clientX+','+e.clientY+' offset='+e.offsetX+','+e.offsetY);
  33. });
  34. El.addEventListener('mousedown',function(e){
  35. console.log('Feather mousedown client='+e.clientX+','+e.clientY+' offset='+e.offsetX+','+e.offsetY);
  36. });
  37. El.addEventListener('mouseup',function(e){
  38. console.log('Feather mouseup client='+e.clientX+','+e.clientY+' offset='+e.offsetX+','+e.offsetY);
  39. });
  40. El.addEventListener('pointerdown',function(e){
  41. console.log('Feather pointerdown client='+e.clientX+','+e.clientY+' offset='+e.offsetX+','+e.offsetY);
  42. El.setPointerCapture(e.pointerId);
  43. });
  44. El.addEventListener('pointerup',function(e){
  45. console.log('Feather pointerup client='+e.clientX+','+e.clientY+' offset='+e.offsetX+','+e.offsetY);
  46. El.releasePointerCapture(e.pointerId);
  47. });
  48. var Bird = document.getElementById('bird');
  49. Bird.addEventListener('mousemove',function(e){
  50. console.log('Bird mousemove client='+e.clientX+','+e.clientY+' offset='+e.offsetX+','+e.offsetY);
  51. });
  52. var Bear = document.getElementById('bear');
  53. Bear.addEventListener('mousemove',function(e){
  54. console.log('Bear mousemove client='+e.clientX+','+e.clientY+' offset='+e.offsetX+','+e.offsetY);
  55. });
  56. });
  57. </script>
  58. Very first line
  59. <div id="bear" style="width:500px;">
  60. Another good line
  61. </div>
  62. <div id="bird" style="width:500px;">
  63. revised <span id="beak">and annotated</span> with brand-new illustrations
  64. <div id="wing" onclick="Show()">
  65. <div id="feather" style="width:201px">
  66. revised and annotated with brand-new illustrations
  67. </div>
  68. one two three four five six seven eight nine ten eleven twelf
  69. <div style="width:20%">
  70. This property may also be set by using the overflow shorthand property
  71. </div>
  72. <div style="position: absolute; left: 0px; top: 0px; width: 100px; border-color: red;">
  73. Bird
  74. </div>
  75. </div>
  76. </div>
  77. </body>
  78. </html>