Foros del Web » Programando para Internet » Jquery »

Animate como en jQuery

Estas en el tema de Animate como en jQuery en el foro de Jquery en Foros del Web. Hola, Como se puede hacer un animate como el de jQuery o el del FBJS (javasript de facebook). Se que es dificil, estuve muchos dias ...
  #1 (permalink)  
Antiguo 05/05/2009, 18:06
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Sonrisa Animate como en jQuery

Hola,
Como se puede hacer un animate como el de jQuery o el del FBJS (javasript de facebook).
Se que es dificil, estuve muchos dias intentando sacarle al jquery su animate pero no puede
Gracias
Salu2
__________________
Half Music - www.halfmusic.com
  #2 (permalink)  
Antiguo 05/05/2009, 19:42
 
Fecha de Ingreso: octubre-2004
Mensajes: 289
Antigüedad: 19 años, 7 meses
Puntos: 10
Respuesta: Animate como en jQuery

Pon un enlace para ver de qué hablas.

Saludos
  #3 (permalink)  
Antiguo 06/05/2009, 06:41
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Animate como en jQuery

Quizá te sirva leer esto: http://www.disegnocentell.com.ar/notas2.php?id=239
  #4 (permalink)  
Antiguo 06/05/2009, 12:45
Avatar de 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

Gracias!
Ahora me pongo a hacerlo (:
__________________
Half Music - www.halfmusic.com
  #5 (permalink)  
Antiguo 06/05/2009, 14:46
Avatar de 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

Hola,
Este es mi codigo del animate:
Código javascript:
Ver original
  1. transicionAnimate:function(curva,ms,callback){
  2.     this.ant=0.01;
  3.     this.done_=false;
  4.     var _this=this;
  5.     this.start=new Date().getTime();
  6.     this.init=function(){
  7.         setTimeout(function(){
  8.                 if(!_this.next()){
  9.                     callback(1);
  10.                     _this.done_=true;
  11.                     window.globalIntervalo=0;
  12.                     return;
  13.                 }
  14.                 callback(_this.next());
  15.                 _this.init();
  16.             },13);
  17.     }
  18.     this.next=function(){
  19.         var now=new Date().getTime();
  20.         if((now-this.start)>ms)
  21.             return false;
  22.         return this.ant=curva((now-this.start+.001)/ms,this.ant);
  23.     }
  24. },
  25. senoidal:function(p,ant){return (1 - Math.cos(p * Math.PI)) / 2;},
  26. fxAnimate:function(obj,efectos,ms,cola,curva){
  27.     if(!window.globalIntervalo)
  28.         window.globalIntervalo=1;
  29.         else{
  30.             if(cola)
  31.                 return setTimeout(function(){this.fxAnimate(obj,efectos,ms,cola,curva)},30);
  32.             else
  33.                 return;
  34.     }  
  35.     var t=new this.transicionAnimate(
  36.     curva,ms,function(p){
  37.         for(at in efectos){
  38.             if(efectos[at]<obj.css(at)){
  39.                 var delta=obj.css(at)-efectos[at];
  40.                 obj.css(at,(obj.css(at)-(p*delta)));
  41.             }else{
  42.                 var delta=efectos[at]-obj.css(at);
  43.                 obj.css(at,(obj.css(at)+(p*delta)));
  44.             }
  45.         }
  46.     });
  47.     t.init();
  48.     t=null;
  49. },
  50. animate:function(op,time){this.fxAnimate(this,op,time,true,this.senoidal);}
Pero no anda bin :(
Me lo hace muy grande (miles de veses mas) y resien al fina me lo hace del tamaño que le di.
Gracias
Salu2
PD: css() es una funcion parecida a jquey.

{EDITO}
Aqui esta el link de una demo:
http://halfmusic.com.ar/animate.html
__________________
Half Music - www.halfmusic.com

Última edición por pato12; 06/05/2009 a las 14:53 Razón: Poner link
  #6 (permalink)  
Antiguo 07/05/2009, 14:20
Avatar de 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
  #7 (permalink)  
Antiguo 08/05/2009, 15:06
Avatar de 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

Nadie sabe como solucionar el problema del opacity?
__________________
Half Music - www.halfmusic.com
  #8 (permalink)  
Antiguo 09/05/2009, 18:54
 
Fecha de Ingreso: octubre-2004
Mensajes: 289
Antigüedad: 19 años, 7 meses
Puntos: 10
Respuesta: Animate como en jQuery

Mira si esto te ayuda para el código de la transparencia:

http://www.box.net/shared/hmyizyxxct

Saludos
  #9 (permalink)  
Antiguo 09/05/2009, 23:53
Avatar de 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

El codigo que hace la trasparencia anda bien, lo que anda mal es que me deja siempre 1 o 0, nunca 0.5 o otros.
Gracias
Salu2
__________________
Half Music - www.halfmusic.com
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:50.