JavaScript makes loading animation effect loading effect _javascript skill

Source: Internet
Author: User

Copy Code code as follows:

Delay wait Effect of/*ajax submission * *

var ajaxloding = new Object ();

Wraperid: container element showing loding picture
MS: Indicates the length of time that the loding icon displays, milliseconds
Envent: An event source object representing the starting event that is used to obtain the object of the starting event
Callback: Represents a fallback method that is performed after an animation has ended
The Stop () method represents the operation of a hidden animation that was performed after the callback method was executed successfully
Ajaxloding.load = function (lodingid,ms,event,left,top,callback) {

if (!left | | typeof left = = undefined)
left = 0;
if (!top | | typeof top = = undefined)
top = 0;

This.lodingid = Lodingid; Displays the parent element for the loding icon
This.obj = $ ("#" + This.lodingid);
this.sourceeventelement=$ (Event.currenttarget);
This.start = function () {
This.obj.css ({positin: "relative"});
This.sourceEventElement.attr ("Disabled", true);
By default, the icons are centered and Lodingid displayed, and the following styles are set
var imgobj = $ (" ');
Imgobj.css ({left:this.obj.width ()/2-imgobj.width ()/2-left, Top:this.obj.height ()/2-imgobj.height ()/2-top});
Imgobj.appendto (This.obj);
This.obj.animate ({height:this.obj.height ()}, MS, function () {
Callback ();
});
};
This.stop = function () {
$ ("#img_loding"). Remove ();
This.sourceEventElement.attr ("Disabled", false);
}
};



Call Method:

Copy Code code as follows:

$ ("#elementid"). Click (function (e) {
var obj = new Ajaxloding.load ("Div_test", 2000,e,0,0,function () {
Alert ("Submit successfully!");
Obj.stop ()//Hide load icon
});
Obj.start ();
});

This is the loding icon that I use, you can replace it by yourself.

Related Article

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.