comparison CADDSuite/data/OpenBabel/svgformat.script @ 0:bac3c274238f

Migrated tool version 0.93 from old tool shed archive to new tool shed repository
author marcel
date Tue, 07 Jun 2011 16:43:30 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bac3c274238f
1 <script type="text/ecmascript">
2 <![CDATA[
3 addEventListener('DOMMouseScroll', wheel, false);
4 onmousewheel = wheel;
5 var svgEl = document.getElementById("topsvg");
6 var startx=0;
7 var starty=0;
8 function wheel(evt){
9 evt = evt ? evt : window.event;
10 var normal = evt.detail ? evt.detail * -1 : evt.wheelDelta / 40;
11 var vb = new Array(4);
12 var vbtext = svgEl.getAttributeNS(null,"viewBox");
13 vb = vbtext.split(" ");
14 var zoom = (normal<0)? 1.41 : 0.71;
15 //var dwidth = parseFloat(Math.max(vb[2],vb[3])) * (1-zoom);
16 vb[0] = parseFloat(vb[0]) + parseFloat(vb[2])*(1-zoom) * evt.clientX/innerWidth;
17 vb[1] = parseFloat(vb[1]) + parseFloat(vb[3])*(1-zoom) * evt.clientY/innerHeight;
18 vb[2] = parseFloat(vb[2]) * zoom;
19 vb[3] = parseFloat(vb[3]) * zoom;
20 svgEl.setAttributeNS(null, "viewBox", vb.join(" "));
21 }
22 onmousedown = function(evt) {
23 startx = evt.clientX;
24 starty = evt.clientY;
25 }
26 onmousemove=function(evt) {
27 if(startx!=0 && starty!=0
28 && ((evt.clientX - startx)*(evt.clientX - startx)+(evt.clientY - starty)*(evt.clientY - starty)>100))
29 {
30 var vbtext = svgEl.getAttributeNS(null,"viewBox");
31 vb = vbtext.split(" ");
32 var maxwh = Math.max(parseFloat(vb[2]),parseFloat(vb[3]));
33 vb[0] = parseFloat(vb[0]) - (evt.clientX - startx)*maxwh/innerWidth;
34 vb[1] = parseFloat(vb[1]) - (evt.clientY - starty)*maxwh/innerHeight;
35 svgEl.setAttributeNS(null, "viewBox", vb.join(" "));
36 startx = evt.clientX;
37 starty = evt.clientY;
38 }
39 }
40 onmouseup=function() {
41 startx=0;
42 starty=0;
43 }
44 ]]>
45 </script>