javascript 使用 .hide('slide') 进行缓和?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16480004/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 04:52:09  来源:igfitidea点击:

Easing with .hide('slide')?

javascriptjqueryjquery-effects

提问by Josh Boothe

Is it possible to have easing with this:

是否有可能对此有所缓解:

('#sideBar').hide('slide', {direction: 'right' }, 
    800, function(){...});

At the moment it is very jittery as it is moving maybe.. 100 - 500 pixels (depending on content). I have been looking google and most people say to use easing, but when looking at the documentation i cannot see a property for easing.

目前它非常紧张,因为它可能正在移动...... 100 - 500 像素(取决于内容)。我一直在寻找谷歌,大多数人都说要使用缓动,但是在查看文档时,我看不到缓动的属性。

采纳答案by billyonecan

You can specify the easingproperty in the optionsobject (the second argument):

您可以easingoptions对象中指定属性(第二个参数):

$('#sideBar').hide('slide', { direction: 'right', easing: 'easeOutBounce' }, 
    800, function(){...});

Check out the easing documentation

查看缓动文档

Here's an example

这是一个例子

回答by Maloric

You can download the JQuery easing plugin from http://gsgd.co.uk/sandbox/jquery/easing, which provides smoother animations than the default ones included with jQuery. You can then easily set your global easing animation using the following code:

您可以从http://gsgd.co.uk/sandbox/jquery/easing下载 JQuery 缓动插件,它提供比 jQuery 中包含的默认动画更流畅的动画。然后,您可以使用以下代码轻松设置全局缓动动画:

jQuery.easing.def = "easeInOutExpo";

You can of course choose whichever easing animation you prefer. This will affect all of your jQuery animations on the page, which isn't a bad thing if you're looking for consistency.

您当然可以选择您喜欢的任何缓动动画。这将影响页面上的所有 jQuery 动画,如果您正在寻找一致性,这并不是一件坏事。

回答by Kishan Patel