Debian Codegraph @

closure-library/closure/goog/demos/dragger.html

raw
1 <!DOCTYPE html>
2 <html>
3 <!--
4 Copyright 2010 The Closure Library Authors. All Rights Reserved.
5
6 Use of this source code is governed by the Apache License, Version 2.0.
7 See the COPYING file for details.
8 -->
9 <head>
10 <title>goog.fx.Dragger</title>
11 <script src="../base.js"></script>
12 <script>
13
14 goog.require('goog.events');
15 goog.require('goog.events.EventType');
16 goog.require('goog.fx.Dragger');
17 goog.require('goog.fx.Dragger.EventType');
18
19 </script>
20 <link rel="stylesheet" href="css/demo.css">
21 <style>
22
23 #stopper {
24 position: absolute;
25 padding: 5px;
26 right: 20px;
27 top: 20px;
28 width: 100px;
29 height: 100px;
30 background: pink;
31 border: 1px solid red;
32 }
33
34 #out {
35 display: inline;
36 background: #eee;
37 border: 1px solid #ddd;
38 padding: 5px;
39 }
40
41 </style>
42 </head>
43 <body>
44
45 <h1>goog.fx.Dragger</h1>
46
47 <p>This demo shows how to use a dragger to capture mouse move events. It tests
48 that you can drag things outside the window and that alerts ends the dragging.
49
50 <h2 id=test onclick="alert('Click')">Drag me</h2>
51 <pre id=out>Status</pre>
52
53 <div id=stopper onmouseover="alert('Stop!')">Drag over me to generate an
54 alert</div>
55
56 <script>
57
58 function update(e) {
59 print(e.clientX + ', ' + e.clientY);
60 }
61
62 function print(s) {
63 document.getElementById('out').innerHTML = s;
64 }
65
66 var testEl = document.getElementById('test');
67
68 goog.events.listen(testEl, goog.events.EventType.MOUSEDOWN, function(e) {
69
70 var d = new goog.fx.Dragger(testEl);
71 d.addEventListener(goog.fx.Dragger.EventType.DRAG, function(e) {
72 update(e);
73 });
74 d.addEventListener(goog.fx.Dragger.EventType.END, function(e) {
75 print('finish');
76 d.dispose();
77 });
78 d.startDrag(e);
79 });
80
81 </script>
82 </body>
83 </html>