queue()/dequeue()
These two methods are as hidden as Ajax’s XMLHttpRequest object and are not known to ordinary people. These two methods are very useful when processing animations. We often write some code like this
$('#test').animate({
"width": "300px",
"height": "300px",
"opacity":"1"
});
In this way, the height, width, and opacity of the test div change at the same time. Sometimes we don’t want to execute it synchronously, but separate the change of shape and the change of transparency. First it becomes a 300*300 div, and then the transparency gradually changes. , we need to write like this
$('#test').animate({
"width": "300px",
"height": "300px",
}, function () {
"$('#test').animate({ "opacity": "1 " });
});
Students can imagine what the code would look like if there were ten animation processes. queue() and dequeue() can solve such problems. Create a queue for all process methods and let the functions be called in sequence. First Take a look at the syntax
queue( [queueName ], newQueue ) The operation wants to execute the queue method
The first parameter is the queue name. If not written, the default is fx
The second parameter can be a function array to store all queue functions, or it can be a callback function to add new functions to the queue
dequeue( [queueName ] ) Execute the next function in the queue for the matching element
Every time this method is called, the next function in the queue is executed
var q = [
🎜> $(this).animate({
“ 🎜>
function next(){
$('#test').dequeue('myQueue');
}
$('#test').queue('myQueue', q);
The above code can make the test div first change to 200*200, and then change to 400*400. Each animation executes the callback function, calls the next method in the queue, and the two animations are executed in sequence. If If you want to add a function during execution, you can do this
Copy code
The code is as follows:
var q = [
function () {
$(this).animate({
"width": "200px",
"height":"200px"
}, next)
},
function () {
$(this).animate({
"width": "400px",
"height": "400px"
}, next);
}
];
function next(){
$('#test').dequeue('myQueue');
}
$('#test').queue('myQueue', q);
next();
$('#test').queue('myQueue',function () {
$(this).slideUp().dequeue('myQueue');
});
总而言之这两个方法就是为了方便动画按照预定次序执行
clearQueue() /stop()
这两个方法主要是为了取消动画
clearQueue( [queueName ] ) 将队列中函数清空
stop( [queue ] [, clearQueue ] [, jumpToEnd ] ) 用于停止正在进行的动画
queue:正在进行的动画队列名称
clearQueue:默认值为false,是否将队列本身也清空
jumpToEnd:默认值为false,是否立即执行完动画
如果想停止刚才动画可以这么写
这样写不会不会终止动画,只是当前动画执行完后,不会再调用队列中下一个动画(队列被清空了嘛,没有下一个了),如果想立即停止动画,可以这么写
As for whether the stop animation is paused or executed immediately, you need to configure the parameters of stop()
slideDown()/ slideUp()/ slideToggle()
The slide effect is often used when making animations, especially menus. These three functions are very simple, that is, the element shrinks/stretches/automatically determines the shrinking and stretching, but its parameters are not only duration, we can also add For some other controls, take a look at the introduction in the API. The Sanger function parameters are similar. Here is an example of slideUp
slideUp( [duration ] [, easing ] [, complete ] ) easing is a gradient method. I have never changed this manually. If duration is not written, it will take about one second to complete the animation by default
slideUp(options)
Commonly used configurations in options include
duration: animation time
queue: You will understand this after reading the above
step: Executed every time the attribute changes during the animation
complete: Executed when the animation is completed
start: Executed when the animation starts
always: Occurs when the animation is terminated or unexpectedly fails to complete
These three functions will modify the height of the element when executed. After sideUp() is executed, the height will be restored and the dialog will be set to none
fadeIn()/ fadeOut()/ fadeToggle()/ fadeTo()
The usage of fadeIn()/ fadeOut()/ fadeToggle() is similar to the slide series, no longer Explain one by one, only these three functions modify the transparency of the element. After the fadeOut() function is executed, it will restore the opacity of the element and set the display attribute to none
fadeTo( duration, opacity [, easing ] [, complete ] ) The fadeTo() method is not that complicated, but the duration and opacity of fadeTO() are not omissible and must be written
show()/ hide()/ toggle()
The usage of these three functions is the same as the slide series, but there are a few differences in effects
1. If the parameter duration is not written, it will be executed immediately without animation
2. This animation modifies the height, width, and opacity attributes at the same time
3. After the execution of hide() is completed, the height, width, and opacity attributes will be restored, and the display will be set to none
animate()
Some complex animations cannot be realized by relying on the above functions. This is when the powerful animate comes in handy. There are two ways to use animate()
.animate( properties [, duration ] [, easing ] [, complete ] )
Most attributes do not need explanation. Properties are json. The value of the attribute can be a literal, function, "toggle", or simple expression. If it is a function, the return value will be assigned to the attribute. Students who are familiar with jQuery will definitely understand." What is "toggle" is to switch an attribute between the initial value and the minimum value. The attributes that can use toggle include width, height, opacity, etc., including numeric value attributes. The simple expressions are =, -=, etc., for example, it can be like this "width":" =10px".
$( "#block" ).animate({
width: "70%",
opacity: 0.4,
marginLeft: "0.6in",
fontSize: "3em",
borderWidth: " =10px"
}, 1500 );
If a callback function is passed in, the function will be called after the animation is executed
.animate( properties, options )
This usage is more flexible, the properties are the same as the previous usage, and the commonly used options are
duration: animation time
queue: function queue
step: the rollback function for each attribute adjustment
complete: the callback function to complete the animation
start: Called when the animation starts
always: Occurs when the animation is terminated or unexpectedly fails to complete
If jQuery is easy to use, are the above configurations very familiar?
$( "#book" ).animate({
width: "toggle",
height: "toggle"
}, {
duration: 5000,
specialEasing: {
width: "linear",
height: " easeOutBounce"
},
complete: function() {
$( this ).after( "
}
} );
hover()
Strictly speaking, this is not an animation function, but because the hover of lower versions of IE does not work for many elements, many actions cannot be completed with CSS, so it is often used. JavaScript handles the haver event.
.hover( handlerIn(eventObject), handlerOut(eventObject) )
The method is very simple, I won’t introduce it in detail, so you can write mousein and mouseout together.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

Python is more suitable for data science and machine learning, while JavaScript is more suitable for front-end and full-stack development. 1. Python is known for its concise syntax and rich library ecosystem, and is suitable for data analysis and web development. 2. JavaScript is the core of front-end development. Node.js supports server-side programming and is suitable for full-stack development.

JavaScript does not require installation because it is already built into modern browsers. You just need a text editor and a browser to get started. 1) In the browser environment, run it by embedding the HTML file through tags. 2) In the Node.js environment, after downloading and installing Node.js, run the JavaScript file through the command line.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.