jquery animate voler et s'arrête après un certain temps
-
12-12-2019 - |
Question
Dites par exemple, j'ai une animation exécutant sur le vol stationnaire, il est naturellement facile de s'arrêter sur notre fonction de rappel - j'ai besoin d'arrêter l'animation après 1 seconde, je ferais-moi cela avec ClearInterval?Ma fonction réelle peut être vue ici http://jsfiddle.net/7hujh/
$(elem).hover(function() {
// animate
}, function () {
// stop animating
});
La solution
Oui, effacez simplement l'intervalle après une seconde:
setTimeout(function() {clearInterval(vibrateIndex);}, 1000);
Autres conseils
$(elem).hover(function() {
$("#item").animate({property:value},interval).delay(1000).stop(0,0);
}, function () {
// stop animating
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow