1 | <!DOCTYPE html> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" /> |
---|
5 | <!-- include jquery --> |
---|
6 | <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script> |
---|
7 | |
---|
8 | <!-- include jquery.ui components --> |
---|
9 | <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script> |
---|
10 | <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.resizable.js"></script> |
---|
11 | <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.draggable.js"></script> |
---|
12 | |
---|
13 | <style type="text/css"> |
---|
14 | #resizable { width: 100px; height: 100px; background: silver; border: 2px dotted black;} |
---|
15 | </style> |
---|
16 | |
---|
17 | <script type="text/javascript"> |
---|
18 | |
---|
19 | // patch it... |
---|
20 | function applyPatch() |
---|
21 | { |
---|
22 | $.ui.plugin.add("resizable", "isDraggable", |
---|
23 | { |
---|
24 | start: function(event, ui) |
---|
25 | { |
---|
26 | var scroll = ui.element.scrollParent(); |
---|
27 | if(scroll) |
---|
28 | { |
---|
29 | ui.originalPosition.top += scroll.scrollTop(); |
---|
30 | ui.position.top += scroll.scrollTop(); |
---|
31 | |
---|
32 | ui.originalPosition.left += scroll.scrollLeft(); |
---|
33 | ui.position.left += scroll.scrollLeft(); |
---|
34 | } |
---|
35 | } |
---|
36 | }); |
---|
37 | } |
---|
38 | |
---|
39 | $(document).ready(function() |
---|
40 | { |
---|
41 | $("#resizable").resizable({ handles: 'all', isDraggable: true}); |
---|
42 | $("#resizable").draggable(); |
---|
43 | }); |
---|
44 | |
---|
45 | </script> |
---|
46 | </head> |
---|
47 | <body style="font-size:62.5%;"> |
---|
48 | |
---|
49 | <h2> |
---|
50 | <a href="#" onclick="applyPatch();"> apply patch! </a> |
---|
51 | </h2> |
---|
52 | |
---|
53 | <div id="imgdivholder" style="width:500px; height:500px; overflow:auto; position:relative;" > |
---|
54 | <div id="resizable" style="position: absolute;"></div> |
---|
55 | <img id="image" src = "http://odo.dwds.de/dta2/lachmann/nibelungen/1816/image/40/0009/"/> |
---|
56 | </div> |
---|
57 | |
---|
58 | </body> |
---|
59 | </html> |
---|