Reproducir la transformación CSS3 con jQuery
-
27-10-2019 - |
Pregunta
Hola, ¿hay alguien que me pueda mostrar para reproducir este efecto CSS3 con jQuery usando una velocidad de retraso/animación?
.element:hover{
-moz-transform: scale(1.3) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);
-webkit-transform: scale(1.3) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);
-o-transform: scale(1.3) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);
-ms-transform: scale(1.3) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);
transform: scale(1.3) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);
z-index:9999;
}
Solución
Aquí hay algo bastante cercano a lo que estás preguntando. Estoy seguro de que podrías ajustarlo a tu gusto
$('.element').hover(function(){
$(this).css('position','relative').animate({
height: $(this).height()*1.3,
width: $(this).width()*1.3,
left: '-=' + $(this).width() /4,
top: '-=' + $(this).height() /4,
'fontSize': $('.element').css('fontSize').substring(0,$('.element').css('fontSize').length -2) * 1.3 + 'px'
},'fast');
},
function() {
$(this).css('position','relative').animate({
height: $(this).height()/1.3,
width: $(this).width()/1.3,
left: 0,
top: 0,
'fontSize': $('.element').css('fontSize').substring(0,$('.element').css('fontSize').length -2) / 1.3 + 'px'
},'fast');
}
);
Otros consejos
Así es como podría implementar una rotación simple (no tener en cuenta la velocidad de cuadro):
$(function(){
(function(n){
this.interval = n;
this.transform = {
'rotation': 0
};
this.start = function(){
setInterval(this.update, this.interval);
};
this.update = function(){
this.transform['rotation'] = (this.transform.rotation + 10) % 360;
$('div').css('transform', 'rotate(' + this.transform.rotation + 'deg)');
};
return this;
})(30).start();
});
http://jsfiddle.net/dbrecht/82aul/1/
Esto demuestra una animación simple. Debería poder descubrir cómo armar el resto.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow