我如何自动如果.slideDown而来的浏览器底部的滚动页面呢? [英] How do I automatically scroll a page up if .slideDown goes of the bottom of the browser?

查看:210
本文介绍了我如何自动如果.slideDown而来的浏览器底部的滚动页面呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有揭示的每一行经由一个jQuery了slideDown当行被mouseover'd附加信息的表。当鼠标被删除的信息与一个效果基本show除去。

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.

是否能保证该页面作为执行了slideDown或向下滚动显示在同一时间的信息我我将不得不handroll解决这一jQuery的一个简单的方法?

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?

推荐答案

您可以尝试让有多深是最后一排,通过计算他的垂直位置(顶部)和他的身高去。如果该值将通过当前滚动,然后滚动到该值。

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.

//尚未测试

var verticalLimit = $("#lastRow").offset().top + $("#lastRow").height() ;
var currentVerticalScroll = $(window).scrollTop();
if (verticalLimit > currentVerticalScroll){
    $("body").animate({ scrollTop: verticalLimit }, 500);
}

这篇关于我如何自动如果.slideDown而来的浏览器底部的滚动页面呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆