drag.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>goog.fx.Dragger</title>
  5. <meta charset="utf-8">
  6. <link rel="stylesheet" href="css/demo.css">
  7. <script src="../base.js"></script>
  8. <script>
  9. goog.require('goog.fx.Dragger');
  10. goog.require('goog.dom');
  11. goog.require('goog.style');
  12. </script>
  13. <style>
  14. #frame {
  15. position: absolute;
  16. left: 99px;
  17. top: 99px;
  18. width: 802px;
  19. height: 502px;
  20. border: 1px solid #999;
  21. background-color: #F0F0F0;
  22. }
  23. .window {
  24. position:absolute;
  25. left: 150px;
  26. top: 110px;
  27. width: 300px;
  28. height: 100px;
  29. background-color: rgb(200,200,250);
  30. border: 1px solid #99F;
  31. font: bold 11px/18px arial;
  32. text-indent: 10px;
  33. color: #FFF;
  34. }
  35. #win2 {
  36. top:250px;
  37. background-color: rgb(250,200,200);
  38. border: 1px solid #F99;
  39. }
  40. #win3 {
  41. left:500px;
  42. background-color: rgb(150,200,150);
  43. border: 1px solid #6A6;
  44. }
  45. .bar {
  46. position:absolute;
  47. left: 0px;
  48. top: 0px;
  49. width: 300px;
  50. height: 20px;
  51. background-color: #99F;
  52. cursor: default;
  53. }
  54. #win2 .bar { background-color: #F99; }
  55. #win3 .bar { background-color: #6A6; }
  56. #sliderback {
  57. position: absolute;
  58. left: 50px;
  59. top: 98px;
  60. height: 505px;
  61. width: 1px;
  62. font-size: 1px;
  63. background-color: #999;
  64. }
  65. #slider {
  66. position: absolute;
  67. left: 35px;
  68. top: 98px;
  69. width: 30px;
  70. height: 13px;
  71. font: normal 10px verdana;
  72. background-color: #EEE;
  73. color: #000;
  74. text-align:center;
  75. border: 1px solid #999;
  76. cursor: default;
  77. }
  78. #ghostbox {
  79. position: absolute;
  80. left: 100px;
  81. top: 625px;
  82. width: 600px;
  83. height: 20px;
  84. }
  85. .block {
  86. position: absolute;
  87. left: 0px;
  88. top: 0px;
  89. width: 125px;
  90. height: 20px;
  91. font: bold 11px/18px arial;
  92. background-color: #AAA;
  93. color: #EEE;
  94. text-align: center;
  95. border: 1px solid #666;
  96. }
  97. .ghost0 { left: 0px; }
  98. .ghost1 { left: 130px; }
  99. .ghost2 { left: 260px; }
  100. .ghost3 { left: 390px; }
  101. </style>
  102. </head>
  103. <body>
  104. <h1>goog.fx.Dragger</h1>
  105. <p><strong>Demonstrations of the drag utiities</strong>.</p>
  106. <div id="frame"></div>
  107. <div id="win1" class="window"><div class="bar">Drag Me...</div></div>
  108. <div id="win2" class="window"><div class="bar">Drag Me...</div></div>
  109. <div id="win3" class="window"><div class="bar">Drag Me...</div></div>
  110. <div id="sliderback"></div>
  111. <div id="slider">0</div>
  112. <script>
  113. var $ = goog.dom.getElement;
  114. // WINDOW EXAMPLE
  115. //================
  116. var Z = 5;
  117. var limits = new goog.math.Rect(100, 100, 500, 400) ;
  118. var window1 = new goog.fx.Dragger($('win1'), $('win1').firstChild, limits);
  119. var window2 = new goog.fx.Dragger($('win2'), $('win2').firstChild, limits);
  120. var window3 = new goog.fx.Dragger($('win3'), $('win3').firstChild);
  121. window3.setHysteresis(6);
  122. function setZ(e) {
  123. this.target.style.zIndex = Z++;
  124. goog.style.setOpacity(this.target, 0.50);
  125. }
  126. function end(e) {
  127. goog.style.setOpacity(this.target, 1);
  128. }
  129. goog.events.listen(window1, 'start', setZ);
  130. goog.events.listen(window2, 'start', setZ);
  131. goog.events.listen(window3, 'start', setZ);
  132. goog.events.listen(window1, 'end', end);
  133. goog.events.listen(window2, 'end', end);
  134. goog.events.listen(window3, 'end', end);
  135. // SLIDER EXAMPLE
  136. //================
  137. var slider1 = new goog.fx.Dragger($('slider'), null,
  138. new goog.math.Rect(35, 98, 0, 490));
  139. goog.events.listen(slider1, 'drag', function(e) {
  140. var percent = Math.round(100 * (e.top - e.dragger.limits.top) /
  141. e.dragger.limits.height);
  142. $('slider').innerHTML = percent;
  143. });
  144. goog.events.listen(window, 'unload', function(e) {
  145. window1.dispose();
  146. window2.dispose();
  147. window3.dispose();
  148. slider1.dispose();
  149. });
  150. </script>
  151. </body>
  152. </html>
  153. <!--
  154. Copyright 2010 The Closure Library Authors. All Rights Reserved.
  155. Use of this source code is governed by the Apache License, Version 2.0.
  156. See the COPYING file for details.
  157. -->