如何使用 jQuery 恢复动画?
我想知道如何使用 jQuery 恢复此动画,请查看此页面:
正确的方法是,当您单击“Equipo”时,它会显示平滑的动画,再次单击它,它会很好地恢复动画。
错误的方法是当您单击“Arquitectura”时,它会开始平滑的动画,然后再次单击此...它看起来很混乱并且不会恢复动画...
我尝试制作.toggle();
方法,但没有工作 3 次,我不知道为什么......
有一个 Arquitectura 脚本:
$('h2#arq').click(function() {
$('section#pryctA4, section#ext').animate({
opacity: 'toggle',
height: 'toggle',
margin: 20
}, {
duration: 750,
specialEasing: {
width: 'linear',
height: 'easeInOutQuad'},
}
);
});
另一个 “Equipo 脚本“如果您愿意:
$('h2#equipo').click(function() {
$('section#team').animate({
opacity: 'toggle',
height: 'toggle'
}, {
duration: 750,
specialEasing: {
width: 'linear',
height: 'easeInOutQuad'},
}
);
});
提前致谢!
I'm wondering how to revert this animation using jQuery, look this page:
The correct way is when you click "Equipo", it shows smooth animation and click this again, it reverts animation very well.
The incorrect way is when you click "Arquitectura", it starts smooth animation, and click this again... it looks like messed up and doesn't revert animation...
I tried to make .toggle();
methods but it didn't work 3 times, i had no idea why...
There is a script of Arquitectura:
$('h2#arq').click(function() {
$('section#pryctA4, section#ext').animate({
opacity: 'toggle',
height: 'toggle',
margin: 20
}, {
duration: 750,
specialEasing: {
width: 'linear',
height: 'easeInOutQuad'},
}
);
});
Another script of "Equipo" if you want:
$('h2#equipo').click(function() {
$('section#team').animate({
opacity: 'toggle',
height: 'toggle'
}, {
duration: 750,
specialEasing: {
width: 'linear',
height: 'easeInOutQuad'},
}
);
});
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
margin
属性没有切换(在动画中 in 两次,都会产生不稳定的效果):修复它的肮脏方法是包含一个内联
if< /code>:
不确定是否存在另一个更优雅的解决方案。
Your
margin
property isn't toggling (in animates in both times, giving the jerky effect):The dirty way to fix it is to include an inline
if
:Not sure if another more elegant solution exists.