如果 .slideDown 超出浏览器底部,如何自动向上滚动页面?
我有一个表格,当鼠标悬停在行上时,通过 jQuery SlideDown 显示每行的附加信息。当鼠标移开时,信息将通过向上滑动删除。
这很好用,但是当我将鼠标悬停在页面上的最后一个项目上时,它会滑到浏览器窗口底部下方。如果用户使用鼠标滚轮或类似工具向下滚动,他们可以看到信息,但如果他们移动鼠标指针来滑动滚动条,信息就会消失。
jQuery 中有没有一种简单的方法可以确保页面向下滚动以在执行 SlideDown 的同时显示信息,或者我是否必须手动解决此问题?
I have a table that reveals additional information for each row via a jQuery slideDown when the row is mouseover'd. When the mouse is removed the information is removed with a slideUp.
This works nicely but when I mouseover the last item on the page it slides down below the bottom of the browser window. If the user scrolls down with a mousewheel or similar they can see the information but if they move the mouse pointer to slide the scroll bar the information disappears.
Is there a simple way in jQuery of ensuring that the page is scrolled down to show the information at the same time as the slideDown is executed or am I going to have to handroll a solution to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试通过计算最后一行的垂直位置(顶部)和高度来了解最后一行的深度。如果该值将通过当前滚动,则您滚动到该值。
//未测试
You could try to get how deep is the last row going by calculating his vertical position (top) and his height. If that value would pass the current scroll, then you scroll to that value.
//Not tested