Ver Mensaje Individual
  #6 (permalink)  
Antiguo 07/05/2009, 14:20
Avatar de pato12
pato12
 
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Respuesta: Animate como en jQuery

Bueno termine el animate.
Les dejo el link para que vean y el codigo:
http://halfmusic.com.ar/animate-finisch.html
Código javascript:
Ver original
  1. <script>
  2. var transicionAnimate=function(curva,ms,callback,onDone){
  3.     this.ant=0.01;this.done_=false;var _this=this;this.start=new Date().getTime();this.init=function(){
  4.     setTimeout(function(){
  5.         if(!_this.next()){
  6.         callback(1);_this.done_=true;(onDone?onDone():function(){
  7.         }
  8.         );window.globalIntervalo=0;return;}
  9.         callback(_this.next());_this.init();
  10.     },13);};
  11.     this.next=function(){
  12.         var now=new Date().getTime();if((now-this.start)>ms)return false;return this.ant=curva((now-this.start+.001)/ms,this.ant);}
  13. }
  14. var senoidal=function(p,ant){return (1 - Math.cos(p * Math.PI)) / 2;}
  15. var fxAnimate=function(obj,efectos,ms,cola,curva,inicio,onDone){
  16.     _this=this;
  17.     if(!window.globalIntervalo)
  18.         window.globalIntervalo=1;
  19.     else{
  20.         if(cola)
  21.             return setTimeout(function(){_this.fxAnimate(obj,efectos,ms,cola,curva,inicio,onDone)},30);
  22.         else
  23.             return;
  24.     }
  25.     var t=new this.transicionAnimate(curva,ms,function(p){
  26.     for(at in efectos){
  27.         if(efectos[at]<inicio[at]){
  28.             var delta=parseInt(inicio[at]-efectos[at]);
  29.             if(at=="opacity"){
  30.                 obj.style.opacity=(parseInt(inicio[at]-parseInt(p*delta)));
  31.                 obj.style.MozOpacity=(parseInt(inicio[at])-parseInt(p*delta));
  32.                 obj.style.KhtmlOpacity=(parseInt(inicio[at])-parseInt(p*delta));
  33.                 obj.style.filter="alpha(opacity="+(parseInt(inicio[at])-parseInt(p*delta))*100+")";
  34.                 obj.style.zoom=1;
  35.             }else{
  36.                 obj.style[at] = (parseInt(inicio[at])-parseInt(p*delta));
  37.             }
  38.         }else{
  39.             var delta=parseInt(efectos[at]-inicio[at]);
  40.             if(at=="opacity"){
  41.                 obj.style.opacity=(parseInt(inicio[at])+parseInt(p*delta));
  42.                 obj.style.MozOpacity=(parseInt(inicio[at])+parseInt(p*delta));
  43.                 obj.style.KhtmlOpacity=(parseInt(inicio[at])+parseInt(p*delta));
  44.                 obj.style.filter="alpha(opacity="+(parseInt(inicio[at])+parseInt(p*delta))*100+")";
  45.                 obj.style.zoom=1;
  46.             }else{
  47.                 obj.style[at] = (parseInt(inicio[at])+parseInt(p*delta));
  48.             }
  49.         }
  50.     }
  51.     },onDone);t.init();t=null;
  52. }
  53. var animate=function(_this,op,time,onDone){time=!time?200:time;inicia={};for(at in op){inicia[at]=_this.style[at].replace('px','');}this.fxAnimate(_this,op,time,true,senoidal,inicia,onDone);}
  54. function animar(_this){
  55.     animate(_this,{'height':50,'width':100,'opacity':0.5},null,function(){alert('Fin!');});
  56. }
  57. </script>
  58. <div style="height:200px; width:300px; background-color:#006699;opacity:1;" onClick="animar(this);">Click para animar!</div>
Gracias
Salu2
PD: No anda el opacity. Si alguien sabe como hacerlo andar, por favor digalo (:
__________________
Half Music - www.halfmusic.com