当前位置: 首页 > 工具软件 > smoothscroll > 使用案例 >

mootools_使用MooTools Fx.SmoothScroll平滑滚动

梁烨
2023-12-01

mootools

I get quite a few support requests for my previous MooTools SmoothScroll article and the issue usually boils down to the fact that SmoothScroll has become Fx.SmoothScroll. Here's a simple usage of Fx.SmoothScroll.

我以前的MooTools SmoothScroll文章获得了很多支持请求,问题通常归结为SmoothScroll已经变成Fx.SmoothScroll 。 这是Fx.SmoothScroll的简单用法。

HTML (The HTML)


<a href="#contact">Contact Us</a> <!-- goes down to the contact area -->

<!-- more stuff here -->

<a name="contact" id="contact"></a>
<h2>Contact Us</h2>

<-- more stuff here -->

The only HTML requirement for Fx.SmoothScroll is that all named anchors be given an identical id attribute.

Fx.SmoothScroll的唯一HTML要求是,所有命名的锚都具有相同的id属性。

MooTools JavaScript (The MooTools JavaScript)


new Fx.SmoothScroll({
	duration: 200
},window);

Fx.SmoothScroll accepts two arguments: the area to scroll (defaults to the window) and options for the class. The default options are usually sufficient. One recommendation I do have is to make the duration quick -- no one wants to wait for the animation to finish.

Fx.SmoothScroll接受两个参数:要滚动的区域(默认为窗口)和该类的选项。 默认选项通常就足够了。 我的一项建议是缩短播放时间-没有人愿意等待动画完成。

Happy scrolling!

滚动愉快!

翻译自: https://davidwalsh.name/mootools-fx-smoothscroll

mootools

 类似资料: