JS animated display background picture

Source: Internet
Author: User

Jani is a jquery plugin that animates background images. This plugin is basically a substitute for GIF animations, but he has his benefits. All browsers support animated formats in GIF format, and do not require additional JavaScript code and tags. But the downside is that the GIF format has only 256 colors. And you can't control the display of the picture. This plugin displays animations by loading vertical gif frames and then changing the background-postion of the container so that you are free to control.

Characteristics
    • A lightweight script
    • Very easy to use
    • Can be fully customized via CSS
    • All browsers support

How to use

1. Download the script and include the jquery framework.

2. Add the following code to the head tag:

12
<script type= "Text/javascript" src= ". /jquery-1.3.2.min.js "></script><script type=" Text/javascript "src=". /jani.js "></script>

3, add the corresponding style in CSS, image address:

12345
<style type= "Text/css" >.animation-1 {background:url (./images/sample-animation.gif) no-repeat left top;} </style>

4. Add a container to display the animation in the page:

1
<div id= "Animation-1" ></div>

5. Add the following code to the head tag:

123456
<script type= "Text/javascript" >$ (document). Ready (function () {$ (' #animation-1 '). Jani ({framewidth:100, frameheight:100, speed:100, totalframes:19}); $ (' #animation-1 '). Jani.play ();}); </script>
Methods of Jani
    • Jani.play (); Turn on animation
    • Jani.pause (); Pause animation
    • Jani.stop (); Stop animation
Parameters

The. Jani () method accepts the following several parameters:

    • Width of the Framewidth:frame
    • Frameheight: Height of individual frames
    • Speed: Animation velocity
    • Number of Totalframes:frame
    • Loop: Whether to loop animation, default to True

JS animated display background picture

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.