jQuery:淡出然后滑动
如果要删除某个项目,那么我想将其淡出并向上滑动其他元素以填充空白空间。 现在,当我使用 fadeOut()
时,该项目末尾没有高度,这会导致其他项目向上跳跃(而不是很好地向上滑动)。
如何在 fadeOut()
之后使用 slideUp()
和元素?
If an item is being deleted then I would like to fade it out and slide the other elements up to fill the empty space. Now, when I use fadeOut()
the item doesn't have a height at the end which results in the other items jumping up (instead of sliding up nicely).
How can I slideUp()
and element right after fadeOut()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
听起来最好使用 jQuery fadeTo 命令
工作演示在这里。
通过在前一个命令的回调函数中执行每个命令,该命令将在前一个命令完成之前不会运行; 当元素从 DOM 中移除而没有等待 SlideUp 完成时,就会发生“跳转”。
Sounds like it would be better to use the jQuery fadeTo command
Working Demo here.
By performing each command in the callback function of the preceding command, the command will not run until the previous one completes; a "jump" occurs when the element is removed from the DOM without waiting for the slideUp to complete.
我在 JQuery 1.3.2 上测试了它,它确实有效。
编辑:这是我调用它的代码。 #slide-then-fade 是按钮元素的ID,article-text 是div 标签上的类:
编辑2:修改为使用内置的slideUp。
编辑3:重写为切换,并使用fadeTo
I tested it on JQuery 1.3.2, and it does work.
Edit: This is the code I called it from. #slide-then-fade is the ID of a button element, article-text is a class on a div tag:
Edit 2: Modified to use the built-in slideUp.
Edit 3: Rewritten as a toggle, and using fadeTo
你不能链它吗?
编辑:
也许这会有所帮助?
Can't you chain it?
EDIT:
Maybe this will help instead?
尝试
$('.row').animate({ height: 'toggle', opacity: 'toggle' }, 'slow').slideUp();
演示在这里
Try
$('.row').animate({ height: 'toggle', opacity: 'toggle' }, 'slow').slideUp();
demo Here
fadeOut 函数采用回调函数的第二个可选参数,因此您应该能够执行以下操作:
编辑:忘记添加 fadeOut 的速度作为第一个参数
The fadeOut function takes a second optional argument of a callback function, so you should be able to do something like this:
EDIT: forgot to add the speed of the fadeOut as the first parameter