如何将 jQuery 的动画过渡从线性更改为二次

发布于 2025-01-03 16:29:46 字数 139 浏览 2 评论 0原文

我想我注意到所有 jQuery 转换(例如幻灯片效果)都以线性方式工作。这意味着动画的速度永远不会改变。

我想知道是否可以将其更改为更加二次的行为。这意味着,我希望动画慢慢开始,然后变得更快。

jQuery 有没有办法实现这一点?

I think I noticed that all jQuery transitions (e.g. slide effect) work in a linear way. That means that the speed of the animation never changes.

I wondered if it would be possible to change this to a more quadratic behavior. That means, I want the animation to slowly start and then get faster.

Is there a way in jQuery to accomplish this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝海似她心 2025-01-10 16:29:46

我不认为这是真的,大多数 jQuery 函数都有一个缓动参数(fadeIn/out、slideDown/up)
如果您使用 slideDown (我举了一个例子),您可以指定一个 easing选项默认为 swing。如果你想要它线性,你必须指定它

.slideDown( [duration] [, easing] [, callback] )

取自文档

宽松
从 jQuery 1.4.3 开始,可以使用命名缓动函数的可选字符串。缓动函数指定了
动画在动画中的不同点进行。这
只有 jQuery 库中的缓动实现是默认的,
一种称为摇摆,一种以恒定速度前进的称为
线性。使用插件可以使用更多缓动功能,
最值得注意的是 jQuery UI 套件。

I don't think that's true, most jQuery function have an easing parameter (fadeIn/out, slideDown/up)
If you use slideDown (i make an example) you can specify an easing option which defaults to swing. If you want it linear you must specify it

.slideDown( [duration] [, easing] [, callback] )

Taken from the docs

Easing
As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the
animation progresses at different points within the animation. The
only easing implementations in the jQuery library are the default,
called swing, and one that progresses at a constant pace, called
linear. More easing functions are available with the use of plug-ins,
most notably the jQuery UI suite.

倾城泪 2025-01-10 16:29:46

几乎所有 jquery 过渡都支持缓动:

$('#something').animate( { left: 96 }, 'fast', 'swing' );
// 'swing' is the name of the easing function

此插件中提供了更大的缓动可能性:http ://gsgd.co.uk/sandbox/jquery/easing/

Almost all jquery transitions have support for easing:

$('#something').animate( { left: 96 }, 'fast', 'swing' );
// 'swing' is the name of the easing function

A larger set of easing possibilities are available in this plugin: http://gsgd.co.uk/sandbox/jquery/easing/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文