[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 /* 2 DynAPI Distribution 3 Swiper Animation Extension - originally designed by Erik Arvidsson (http://web.eae.net) 4 IncDec addon - Created by Daniel Tiru (http://www.tiru.se) 5 6 The DynAPI Distribution is distributed under the terms of the GNU LGPL license. 7 8 requires: DynLayer 9 10 */ 11 12 Swiper = {}; // used by dynapi.library 13 14 DynLayer.prototype.swipeTo = function(dir, steps, ms, min) { 15 16 this._swipeSteps = (steps!=null)? steps: 4; 17 this._swipeMS = (ms!=null)? ms:25; 18 this._swipeDir=dir; 19 this._swiperMin=min; 20 if (this._swiperMinimized==null) { 21 this._swiperMinimized = 0 22 } 23 24 if (this.swipeTimer != null) window.clearTimeout(this.swipeTimer); 25 26 if (!this._swipeCnt) { // No animation yet! 27 this._swipeOrgX = this.getX(); 28 this._swipeOrgY = this.getY(); 29 this._swipeOrgWidth = this.getWidth(); 30 this._swipeOrgHeight = this.getHeight(); 31 } 32 33 this._swipeCnt = this._swipeSteps; 34 if (dir.substr(0,3)!='dec' && dir.substr(0,3)!='inc') { 35 this.setClip([0,0,0,0]); 36 } 37 window.setTimeout(this+"._swipe()", this._swipeMS); 38 }; 39 DynLayer.prototype._swipe = function() { 40 var steps = this._swipeSteps; 41 var x = this._swipeOrgX; 42 var y = this._swipeOrgY; 43 var w = this._swipeOrgWidth; 44 var h = this._swipeOrgHeight; 45 var min = this._swiperMin; 46 47 if (this._swipeCnt == 0) { 48 if (this._swipeDir.substr(0,3)!='dec' && this._swipeDir.substr(0,3)!='inc') { 49 this.setClip([0, w, h,0]); 50 } 51 else if(this._swipeDir.substr(0,3)=='dec') { 52 this._swiperMinimized=1; 53 } 54 else if(this._swipeDir.substr(0,3)=='inc') { 55 this._swiperMinimized=0; 56 } 57 this.invokeEvent('swipefinish'); 58 return; 59 } 60 else { 61 this._swipeCnt--; 62 this.setVisible(true); 63 switch (this._swipeDir) { 64 case "bottom": //down (see the numpad) 65 this.setClip([h * this._swipeCnt / steps, w, h, 0]); 66 this.setY(y - h * this._swipeCnt / steps); 67 break; 68 case "top": 69 this.setClip([0, w, h * (steps - this._swipeCnt) / steps, 0]); 70 this.setY(y + h * this._swipeCnt / steps); 71 break; 72 case "right": 73 this.setClip([0, w, h,w * this._swipeCnt / steps]); 74 this.setX(x - w * this._swipeCnt / steps); 75 break; 76 case "left": 77 this.setClip([0, w * (steps - this._swipeCnt) / steps, h, 0]); 78 this.setX(x + w * this._swipeCnt / steps); 79 break; 80 case "bottom-right": 81 this.setClip([h * this._swipeCnt / steps, w, h, w * this._swipeCnt / steps]); 82 this.setX(x - w * this._swipeCnt / steps); 83 this.setY(y - h * this._swipeCnt / steps); 84 break; 85 case "bottom-left": 86 this.setClip([h * this._swipeCnt / steps, w * (steps - this._swipeCnt) / steps, h, 0]); 87 this.setX(x + w * this._swipeCnt / steps); 88 this.setY(y - h * this._swipeCnt / steps); 89 break; 90 case "top-left": 91 this.setClip([0, w * (steps - this._swipeCnt) / steps, h * (steps - this._swipeCnt) / steps, 0]); 92 this.setX(x + w * this._swipeCnt / steps); 93 this.setY(y + h * this._swipeCnt / steps); 94 break; 95 case "top-right": 96 this.setClip([0, w, h * (steps - this._swipeCnt) / steps, w * this._swipeCnt / steps]); 97 this.setX(x - w * this._swipeCnt / steps); 98 this.setY(y + h * this._swipeCnt / steps); 99 break; 100 // inc-dec 101 case "dec-right": 102 if (this._swiperMinimized==0) { 103 if ((w/steps*this._swipeCnt) > min) { 104 this.setClip([0, (w/steps*this._swipeCnt), h, 0]); 105 } 106 else this.setClip([0, min, h, 0]); 107 } 108 break; 109 case "inc-right": 110 //var clippos = this.getClip().toString().split(','); 111 if (this.getClip()[1] < w-(w/steps*this._swipeCnt)) { 112 if (this._swiperMinimized==1) { 113 this.setClip([0, w-(w/steps*this._swipeCnt), h, 0]); 114 } 115 } 116 break; 117 case "dec-left": 118 if (this._swiperMinimized==0) { 119 if ((w/steps*this._swipeCnt) > min) { 120 this.setClip([0, Math.round(w/steps*this._swipeCnt), h, 0]); 121 this.setX(w+(x-(Math.round(w/steps*this._swipeCnt)))); 122 } 123 else{ 124 this.setClip([0, min, h, 0]); 125 this.setX(w+x-min); 126 } 127 } 128 break; 129 case "inc-left": 130 if (this._swiperMinimized==1) { 131 if (this.getClip()[1] < w-Math.round(w/steps*this._swipeCnt)) { 132 this.setClip([0, w-Math.round(w/steps*this._swipeCnt), h, 0]); 133 if (w-(w/steps*this._swipeCnt) < x) { 134 this.setX(x-(w-Math.round(w/steps*(this._swipeCnt)+min))); 135 } 136 else this.setX((steps*w/steps)-(x)); 137 } 138 } 139 break; 140 case "dec-down": 141 if (this._swiperMinimized==0) { 142 if ((h/steps*this._swipeCnt) > min) { 143 this.setClip([0, w, (h/steps*this._swipeCnt), 0]); 144 } 145 else this.setClip([0, w, min, 0]); 146 } 147 break; 148 case "inc-down": 149 if (this._swiperMinimized==1) { 150 if (this.getClip()[2] < h-(h/steps*this._swipeCnt)) { 151 this.setClip([0,w, h-(h/steps*this._swipeCnt), 0]); 152 } 153 } 154 break; 155 case "dec-up": 156 if (this._swiperMinimized==0) { 157 if ((h/steps*this._swipeCnt) > min) { 158 this.setClip([0, w, Math.round(h/steps*this._swipeCnt), 0]); 159 this.setY((h+y-(Math.round(h/steps*this._swipeCnt)))); 160 } 161 else{ 162 this.setClip([0, w, min, 0]); 163 this.setY(h+y-min); 164 } 165 } 166 break; 167 case "inc-up": 168 if (this._swiperMinimized==1) { 169 if (this.getClip()[2] < h-Math.round(h/steps*this._swipeCnt)) { 170 this.setClip([0, w, h-Math.round(h/steps*this._swipeCnt), 0]); 171 if (h-(h/steps*this._swipeCnt) < y) { 172 this.setY(y-(h-Math.round(h/steps*(this._swipeCnt)+min))); 173 } 174 else this.setY((steps*h/steps)-(y-min)); 175 } 176 } 177 break; 178 } 179 this.swipeTimer = window.setTimeout(this+"._swipe()", this._swipeMS); 180 } 181 }; 182
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 |