jquery plug-in Jtimer (jquery timer) method of Use

Source: Internet
Author: User
Many times we need to perform a task at intervals, stopping execution when certain conditions are met. This plugin is designed to address this frequently encountered problem   code as follows: (function ($) {    $.extend ({    &NB Sp   Timer:function (action,context,time) {            var _timer;             if ($.isfunction (action)) {                (function () {&N Bsp                   _timer = setinterval (function () {      &NB Sp                 if (!action (context)) {                            clearinterval (_timer);                                   & nbsp        }, time);                }) ();            }         }    }); }) (JQuery);     Code as follows: <! DOCTYPE html> <html xmlns= "http://www.w3.org/1999/xhtml" > <head>     <meta http-equiv= " Content-type "content=" text/html; Charset=utf-8 "/>     <title> canvas </title>     <script src=". /script/jquery.min.js "></script>     <script src=". /script/jtimer.js "></script>     <style type=" Text/css ">         #wrap & nbsp       {            display:table;             margin:0 Auto;        }           #cvs         {      & nbsp     Display:table-cell;             Vertical-align:middle;        }     </style>     <script type= "Text/javascript" >   &NBS P     function Drawround (context) {                        I F (context.counterclockwise) {                Draw (Context.x, context.y, context. R, Context.start, CONTEXT.START-MATH.PI/50, context.counterclockwise);                 Context.start-= math.pi/50;                 return context.start > 0.5 * MATH.PI;                         else {        & nbsp       Draw (Context.x, Context.y, CONTEXT.R, Context.start, Context.start + math.pi/50, Context.counterclo Ckwise);                 Context.start + = math.pi/50;                 return Context.start < Math.PI;            }       }         function draw (x, Y, R, Sangle, Eangle, counterclockwise) {    &NBSP ;       var cvs = document.getElementById ("CVS");             CTX = Cvs.getcontext ("2d");             Ctx.strokestyle = "#f00";             Ctx.beginpath ();             CTX.ARC (x, Y, R, Sangle, Eangle, counterclockwise);             Ctx.stroke ();        }         $ (function () {            $.time R (Drawround, {x:100, y:100, r:50, start:1.5 * Math.PI, counterclockwise:true}, 200);             $.timer (Drawround, {x:100, y:100, r:60, start:0, Counterclockwise:false}, 200);        });     </script> </head> <body>     <div id= "Wrap";         <canvas id= "CVS" height= "&L" width= "></canvas>"     </div> T;/body> </html>    
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.