平滑滚动因固定页眉/页脚而中断

时间:2015-12-05 15:41:17

标签: jquery smooth-scrolling

我使用以下脚本来平滑滚动可变长度的文章。下面的示例主要是向上滚动到顶部:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content" >

<Button
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="New Button"
    android:textAllCaps="false"
    android:textSize="15pt"
    android:id="@+id/element_button"
    android:layout_gravity="center" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Text"
    android:id="@+id/element_number"
    android:layout_gravity="top|left" />
</FrameLayout>

我如何修改上面的脚本也说&#34;实际上平滑滚动比这更高的100px?&#34;

1 个答案:

答案 0 :(得分:0)

您可以像这样简单地向脚本添加-100:

var duration = ($('#article').outerHeight(true) / 100) * 25 ;
$('html, body').animate({
    scrollTop: $("#article").offset().top - 100
}, duration);