Est-ce que cela peut être fait? Fondamentalement, je veux animer une image positionnée en absolu avec droit: xxxPX, disons. Eh bien, quand l'animation est en cours, puis-je ajouter un effet "trail"?Effet de traînée avec jQuery?
Merci, Adrian
Est-ce que cela peut être fait? Fondamentalement, je veux animer une image positionnée en absolu avec droit: xxxPX, disons. Eh bien, quand l'animation est en cours, puis-je ajouter un effet "trail"?Effet de traînée avec jQuery?
Merci, Adrian
Cela devrait fonctionner:
var box = $('#box'),
// Create some clones (these make up the trail)
clones = $.map(Array(10), function(item, i){
return box.clone().css('opacity', 1/(i + 1)).hide().insertAfter(box);
});
box.animate({
top: 100,
left: 200
}, {
duration: 1000,
step: function(now, fx) {
// On each step, set a timeout for each clone,
// making it move to the required position.
var prop = fx.prop;
$.each(clones, function(i, clone){
clone = $(clone).show();
setTimeout(function(){
clone.css(prop, now);
}, 50 * i);
});
}
});
Démo: http://jsbin.com/ifobe3
comment "piste"? Pourriez-vous être plus précis? – jrharshath
Comme le curseur de fenêtres "effet de traînée"? –
James Goodwin, oui, comme ça – Adrian