我正在尝试使用jQuery实现"摇动动画".我们的想法是,你可以制作一个元素震动来引起人们的注意.以下是我提出的建议:
function DrawAttention(item, count)
{
$(item).animate({top: '+=5'}, 50,
function(){
$(item).animate({top: '-=10'}, 100,
function(){
$(item).animate({top: '+=5'}, 50,
function(){
if(count>0)
{
DrawAttention(item,count-1);
}
});
});
});
}
Run Code Online (Sandbox Code Playgroud)
我觉得这有点冗长,并且想知道是否有人能看到更优雅的方式来实现我想要的东西.
小提琴这里.
function DrawAttention(item, count)
{
$(item)
.animate({top: '+=5'}, 50)
.animate({top: '-=10'}, 100)
.animate({top: '+=5'}, 50, function(){
if(count > 0){
DrawAttention(item,count-1);
}
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1536 次 |
| 最近记录: |