只要我有一个div
应该当我点击一个按钮,当我在另一个按钮,点击进行动画和隐藏:easeOutBounce效果并不总是适用
<div id="popup"></div>
<input type="button" value="show and animate popup" onClick="showWithAnimation()" />
<input type="button" value="hide" onClick="aFunction()" />
<script>
function showWithAnimation(){
console.log('animation called');
$('#popup') .animate({top:(($(window).height()/2)-($('#popup').outerHeight()/2))-70}, 1000, 'easeOutBounce');
$('#popup').show();
}
function aFunction(){//Hide the div
$('#popup').hide();
}
</script>
后来我发现,是反弹效果div
只适用于我第一次点击show and animate popup
,然后当我点击hide
按钮,然后再次点击show and animate popup
按钮,div
显示,但没有效果。我可以问你如何去解决这个问题吗?提前Thanx。
Thanx为此,它的工作原理,虽然我不明白你的解释。你能否以其他方式重新解释:) – Malloc
我更新了答案,希望能帮助解释发生了什么。关键是,即使div关闭时它仍然处于隐藏状态,它仍然处于您为“animate”指定的目标位置。 – Ian