[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 /* 2 DynAPI Distribution 3 Glide Animation Extension 4 5 The DynAPI Distribution is distributed under the terms of the GNU LGPL license. 6 7 requires: dynapi.fx.Thread 8 */ 9 10 function GlideAnimation(x1,y1,x2,y2,angleinc,startSpeed,endSpeed) { 11 if (x2==null) x2 = x1; 12 if (y2==null) y2 = y1; 13 14 var normAngle = dynapi.functions.getNormalizedAngle(x1,y1,x2,y2); 15 var distx = x2-x1; 16 var disty = y2-y1; 17 var distance = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2)); 18 angleinc = (angleinc==null)? 7 : Math.abs(angleinc); 19 20 // a terrible mess but it works 21 var r = 1; 22 if (startSpeed == "fast") { 23 var centerX = x1; 24 var centerY = y1; 25 var centerX2 = x2; 26 var centerY2 = y2; 27 startAngle = 0; 28 endAngle = 90; 29 if (endSpeed=="fast") distance = distance/2; 30 } 31 else { 32 startAngle = -90; 33 endAngle = 0; 34 if (endSpeed == "fast") { 35 var centerX = x1+distx; 36 var centerY = y1+disty; 37 } 38 else { // default slow,slow 39 var centerX2 = x2-distx/2; 40 var centerY2 = y2-disty/2; 41 distance = distance/2; 42 var centerX = x1+distx/2; 43 var centerY = y1+disty/2; 44 r = -1; 45 } 46 } 47 48 var i,d,x,y,dx,dy,path=[]; 49 for (var a=startAngle; a<endAngle; a+=angleinc) { 50 i = path.length; 51 d = distance*Math.sin(a*Math.PI/180); 52 path[i] = Math.round(centerX + d*Math.cos(normAngle)); 53 path[i+1] = Math.round(centerY - d*Math.sin(normAngle)); 54 } 55 if (startSpeed==endSpeed) { 56 for (var a=endAngle; a<endAngle+90; a+=angleinc) { 57 i = path.length; 58 d = distance*Math.sin(a*Math.PI/180); 59 path[i] = Math.round(centerX2 - r*d*Math.cos(normAngle)); 60 path[i+1] = Math.round(centerY2 + r*d*Math.sin(normAngle)); 61 } 62 } 63 64 var l = path.length; 65 if (path[l-2] != x2 || path[l-1]!=y2) { 66 path[l] = x2; 67 path[l+1] = y2; 68 } 69 70 return path; 71 }; 72 73 DynLayer.prototype.glideStop = function () { 74 if (this._thread) this._thread.stop(); 75 }; 76 DynLayer.prototype.glideTo = function(x2,y2,angleinc,ms,startSpeed,endSpeed) { 77 if (this.x!=x2 || this.y!=y2) { 78 if (!this._thread) this._thread = new Thread(this); 79 if (ms) this._thread.interval = ms; 80 this._thread.play(GlideAnimation(this.x,this.y,x2,y2,angleinc,startSpeed,endSpeed) ); 81 } 82 };
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |