10 examples of 'setinterval jquery example' in JavaScript

Every line of 'setinterval jquery example' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
44function setInterval(callback, delay, var_args) {};
13public SetTimeoutExample():number {
14 var intervalId: number = egret.setTimeout(this.myDelayedFunction,this, this.delay, ["Hello", "World"]);
15 return intervalId;
16}
24function setInterval(callback, duration) {
25 if(!callback) return;
26
27 var id = window.timerID++;
28 var info = {id:id, callback:callback};
29
30 info.duration = duration/1000;
31 info.timeout = window.tickTime + info.duration;
32
33 window.intervalFuncs[id] = info;
34
35 return id;
36}
14function setTimeInterval(time) {
15 resetTimeInterval();
16
17 currentTime = time;
18 setTimeText(currentTime);
19
20 interval = setInterval(function() {
21 currentTime -= 1000;
22 setTimeText(currentTime);
23
24 if (currentTime <= 0) {
25 clearInterval(interval);
26 }
27 }, 1000);
28}
29function SetInterval() {
30 this.key = {};
31
32 /**
33 * @param {Function} fn
34 * @param {Number} interval
35 * @param {String} key
36 */
37 this.start = function start(fn, interval, key) {
38 if (!this.key[key]) {
39 this.key[key] = setInterval(function () {
40 fn();
41 }, interval);
42 }
43 }
44
45 /**
46 * @param {String} key
47 */
48 this.clear = function clear(key) {
49 if (this.key[key]) {
50 clearInterval(this.key[key]);
51 delete this.key[key];
52 }
53 }
54}
24function setInterval(handler,time){
25 if (isWeex){
26 timer.setInterval(handler,time);
27 return document.taskCenter.callbackManager.lastCallbackId.toString();
28 } else {
29 return window.setInterval(handler,time);
30 }
31}
25setInterval (interval) {
26 this.options.interval = interval
27 return this;
28}
116function set_interval(a,b)
117{
118 if( This.timer_callback)
119 {
120 console.error('only one timer can be active at a time. please `clearInterval` before setting a new one.');
121 return;
122 }
123 This.timer_callback = a;
124 This.target_interval = b;
125 This.timer = setInterval(frame, This.target_interval*0.5);
126 return This.timer;
127}
43setInterval(callback, intervalMs) {
44 this.callbacks.push(callback);
45}
1function adaptiveSetInterval(fn, runNow) {
2 // unconditionally run every minute
3 setInterval(fn, 60000);
4
5 // scheduleRun() keeps calling fn and decreasing quota
6 // every 3 seconds, until quota runs out.
7 var quota = 0;
8 var scheduledId = null;
9 function scheduleRun() {
10 if (quota > 0) {
11 quota -= 1;
12 clearTimeout(scheduledId);
13 scheduledId = setTimeout(scheduleRun, 3000);
14 fn();
15 }
16 }
17
18 document.addEventListener("visibilitychange", function() {
19 if (document.visibilityState == "visible") {
20 // tab becomes visible: reset quota
21 if (quota == 0) {
22 quota = 20;
23 scheduleRun();
24 } else {
25 quota = 20;
26 }
27 } else {
28 // lost visibility, clear quota
29 quota = 0;
30 }
31 });
32
33 // user moves mouse: reset quota
34 document.addEventListener("mousemove", function() {
35 if (quota == 0) {
36 quota = 20;
37 scheduleRun();
38 } else {
39 quota = 20;
40 }
41 });
42
43 if (runNow) {
44 quota = 20;
45 scheduleRun();
46 }
47}

Related snippets