In-depth learning of jQuery Animate (1)
The content of this article is about in-depth learning of Animate in jQuery (1), so that everyone can further understand the usage of animate in jQuery. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
How much do you know about the usage of animate in jQuery? If it is just a simple move of position, show and hide, oh! Oh my gosh you are wasting resources! Because animate is so powerful, you can use it in many unexpected ways! Let’s study it together. [Related video tutorial recommendations: jQuery Tutorial]
First, you need to understand the detailed usage of animate in jQuery API.
animate: Returns jQuery object
animate( properties [, duration ] [, easing ] [, complete ] )
Description: Perform custom animation based on a set of CSS properties.
1. animate( properties [, duration ] [, easing ] [, complete ] )
1. Properties
Type: PlainObject
An object of CSS properties and values. The animation will move according to this group of objects.
2. Duration (default: 400)
Type: Number or String
A string or number determines how long the animation will run. (Default value: "normal", string "slow", "normal", or "fast" or a millisecond value indicating the animation duration (such as: 1000))
3. easing (default: swing)
Type: String
A string indicating which easing function to use for the transition. (jQuery itself provides "linear" and "swing")
4. complete
Type: Function()
Function executed when the animation is completed.
2. animate( properties, options )
1. Properties
Type: PlainObject
An object of CSS properties and values. The animation will move according to this group of objects.
2, options
Type: PlainObject
A set of values containing animation options. Supported options:
1), duration (default: 400)
Type: Number or String
A string or number determines how long the animation will run. (Fool's Pier Note: Default value: "normal", three predetermined speed strings ("slow", "normal", or "fast") or a millisecond value indicating the animation duration (such as: 1000))
2), easing (default: swing)
Type: String
A string indicating which easing function to use for transition. (Note from Fool's Wharf: jQuery itself provides "linear" and "swing", and you can use the jQuery Easing Plugin for other effects)
3), queue (default: true)
Type: Boolean or String
A Boolean value indicating whether to place the animation in the effects queue. If false, the animation will start immediately. Starting with jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. When a custom queue name is used, the animation does not start automatically; you must call .dequeue("queuename") to start it.
4), specialEasing
Type: PlainObject
One or more CSS properties defined by the first parameter properties of this method, and their corresponding easing functions A map of key-value pairs. (New in 1.4)
5),step
Type: Function(Number now, Tween tween)
Every The function that will be called for each animated property of an animated element. This function provides an opportunity to modify the Tween object to change the property values in the settings.
6)、progress
Type: Function( Promise animation, Number progress, Number remainingMs )
Each step animation A function called upon completion, executing a separate function for each animated element, regardless of how many animation properties there are. (version added: 1.8)
7), complete
Type: Function()
Function executed when the animation is completed.
8), done
Type: Function( Promise animation, Boolean jumpedToEnd )
Function executed when the animation is completed. (His Promise object status has been completed). (version added: 1.8)
9), fail
Type: Function( Promise animation, Boolean jumpedToEnd )
animation failed Function to be executed when completed. (His Promise object status is not completed). (version added: 1.8)
10)、always
Type: Function( Promise animation, Boolean jumpedToEnd )
Executed when the animation is completed or stopped when it is not completed function. (His Promise object status is completed or incomplete). (version added: 1.8)
For some basic applications, you can refer to jQuery API, or jQuery API Chinese.
The orange part is what I want to focus on in this article!
PlainObject
PlainObject类型,是Javascript对象包含0个或者跟多键值对。换句话说,PlainObject也是Object对象。但在jQuery文档中,被设计是为了区分其他多种Javascript对象。如null,用户自定义的数组,或者是主机对象向如document,typeof 值都是 “object”。通过jQuery.isPlainObject()方法来判断传入的的参数是否是PlainObject.
var a = []; var d = document; var o = {}; typeof a; // object typeof d; // object typeof o; // object jQuery.isPlainObject( a ); // false jQuery.isPlainObject( d ); // false jQuery.isPlainObject( o ); // true
queue
一个布尔值,指示是否将动画放置在效果队列中。如果为false时,将立即开始动画。
它是来决定不同动画进行的顺序。
$( "#block1" ).animate( { width: "90%" }, { queue: false, duration: 3000 }) .animate({ fontSize: "24px" }, 1500 ) .animate({ borderRightWidth: "15px" }, 1500 ); $( "#block2" ).animate({ width: "90%" }, 1000 ) .animate({ fontSize: "24px" }, 1000 ) .animate({ borderLeftWidth: "15px" }, 1000 );
#block1要执行的动画中,使用了 queue: false 选项,该动画使元素的宽度扩大到了总宽 90%,并且 文字大小也变大了。一旦字体大小改变完了,边框的动画就会开始。注意到是并且了吗?是同时进行的~~
#block2要执行的动画中,包含了一系列动画,当前一个动画完成时,后一个动画就会开始。
关于 step 就留到下次在讲解吧!
The above is the detailed content of In-depth learning of jQuery Animate (1). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

jQuery is a fast, small, feature-rich JavaScript library widely used in front-end development. Since its release in 2006, jQuery has become one of the tools of choice for many developers, but in practical applications, it also has some advantages and disadvantages. This article will deeply analyze the advantages and disadvantages of jQuery and illustrate it with specific code examples. Advantages: 1. Concise syntax jQuery's syntax design is concise and clear, which can greatly improve the readability and writing efficiency of the code. for example,

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s
