Home > Web Front-end > JS Tutorial > body text

Detailed explanation of jQuery.fx.interval property usage

巴扎黑
Release: 2017-06-30 14:08:07
Original
1762 people have browsed it

jQuery.fx.interval property is used to set or return the frame rate (millisecond value) of animation.

The jQuery.fx.interval property is used to set how many milliseconds every jQuery animation draws a frame of image (triggering a style change, the browser may redraw the current page).

The smaller the value, the more times the animation is triggered, the animation effect is more obvious and smoother, and of course, the more performance is consumed.

When changing the value of this property, the animation queue being executed will not be affected. Any animation queues that have not yet been executed will be animated at the changed frame rate.

This property belongs to the global jQuery object (can also be understood as a static property).

Syntax

jQuery 1.4.3 NewThe static attribute.

jQuery.fx.interval

Return value

The return value of the jQuery.fx.interval property is Number type, returning the frame rate of the animation (millisecond value).

The default value of this attribute is 13.

Example & Description

Please refer to the following HTML sample code:

Frame rate (how many milliseconds a frame is drawn every ):

<select id="frameRate">
        <option value="5">5</option>
        <option value="10">10</option>
        <option value="13" selected="selected">默认(13)</option>
        <option value="20">20</option>
        <option value="50">50</option>
        <option value="100">100</option>
        <option value="300">300</option>
        <option value="1000">1000</option>
    </select>
    <input id="exec" type="button" value="执行动画" />
</p>
<div id="myDiv" style="width:300px; height: 100px; background-color: #ccc;" >CodePlayer</div>
Copy after login

The jQuery sample code related to the jQuery.fx.interval property is as follows:

// 更改帧速
$("#frameRate").change( function(){
    $.fx.interval = this.value; // 设置帧速
} );
// 执行动画
$("#exec").click( function(){
    var $myDiv = $("#myDiv");
    // 在现有高度的基础上增加300px (如果原来是100px,增加后就是400px)
    $myDiv.animate( { height: "+=300px" }, 2000 ); 
    $myDiv.animate( { width: "50%" }, 1000 );       
    $myDiv.animate( { width: "200px", height: "100px" }, 1000 );        
} );
Copy after login

The above is the detailed content of Detailed explanation of jQuery.fx.interval property usage. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template