settimeout

How to save/clear setTimeout's array using loop's index?

可紊 提交于 2020-01-17 04:59:25
问题 I am calling a for loop multiple times. I would like to save a single setTimeout for each index. The idea is to use the loop's index as setTimeout's array index, but setTimeout returns an incremental ID number, I would like to reset it, or override to take control of the returning ID, so I can identify each timeout with a given index, always within the range of loop's index that is executed over and over again. Being able to use clearTimeout later on with a specific index. var timeouts = [];

setTimeout issue trying to wait for execution of async

若如初见. 提交于 2020-01-17 01:17:24
问题 I'm new to this kind of problem in javascript and i can't fix this attempt to wait for an asynchronous call combining Angular promise objects and timeouts. The function onTimeout seems never execute. getAsyncContent: function (asyncContentInfos) { var deferObj = $q.defer(); var promiseObj = deferObj.promise; asyncContentInfos.promiseObject = promiseObj; var blockingGuard = { done: false }; promiseObj.then(function () { blockingGuard.done = true; }); this.wait = function () { var executing =

setTimeout传参

怎甘沉沦 提交于 2020-01-16 10:19:37
var myVar; function myStartFunction() { myVar = setTimeout(alertFunc, 2000, "Runoob", "Google"); } function alertFunc(param1, param2) { document.getElementById("demo").innerHTML += "Hello "; document.getElementById("demo2").innerHTML = "传递给 alertFunc() 的参数: <br>" + param1 + "<br>" + param2 + "<br>"; } 执行结果: 传递给 alertFunc() 的参数: Runoob Google 参考文档: https://www.runoob.com/jsref/met-win-settimeout.html setTimeout(code, milliseconds, param1, param2, ...) setTimeout(function, milliseconds, param1, param2, ...) 参数 描述 code/function 必需。要调用一个代码串,也可以是一个函数。 milliseconds 可选。执行或调用 code/function 需要等待的时间

clearTimeout on Mouse Exit

笑着哭i 提交于 2020-01-15 18:56:43
问题 I have a timer setup like so: var timerID; $this.hover(function(){ $this.find('.stage_obj').each(function(index){ var current_obj = $(this); timerID = setTimeout(function(){ animate_on_top(current_obj, index);}, parseInt(OS.delay_y_on_set[index],10)); }); }, function(){ clearTimeout(timerID); }); There are functions to control the animation in/out on hover. The timers are acting as delays (.delay won't work in my situation). Everything works fine, except the timer isn't cancelled on mouse

clearTimeout on Mouse Exit

淺唱寂寞╮ 提交于 2020-01-15 18:55:45
问题 I have a timer setup like so: var timerID; $this.hover(function(){ $this.find('.stage_obj').each(function(index){ var current_obj = $(this); timerID = setTimeout(function(){ animate_on_top(current_obj, index);}, parseInt(OS.delay_y_on_set[index],10)); }); }, function(){ clearTimeout(timerID); }); There are functions to control the animation in/out on hover. The timers are acting as delays (.delay won't work in my situation). Everything works fine, except the timer isn't cancelled on mouse

clearTimeout on Mouse Exit

空扰寡人 提交于 2020-01-15 18:55:31
问题 I have a timer setup like so: var timerID; $this.hover(function(){ $this.find('.stage_obj').each(function(index){ var current_obj = $(this); timerID = setTimeout(function(){ animate_on_top(current_obj, index);}, parseInt(OS.delay_y_on_set[index],10)); }); }, function(){ clearTimeout(timerID); }); There are functions to control the animation in/out on hover. The timers are acting as delays (.delay won't work in my situation). Everything works fine, except the timer isn't cancelled on mouse

clearTimeout on Mouse Exit

五迷三道 提交于 2020-01-15 18:55:08
问题 I have a timer setup like so: var timerID; $this.hover(function(){ $this.find('.stage_obj').each(function(index){ var current_obj = $(this); timerID = setTimeout(function(){ animate_on_top(current_obj, index);}, parseInt(OS.delay_y_on_set[index],10)); }); }, function(){ clearTimeout(timerID); }); There are functions to control the animation in/out on hover. The timers are acting as delays (.delay won't work in my situation). Everything works fine, except the timer isn't cancelled on mouse

Prevent “Stop running script” when loading large amounts of data

↘锁芯ラ 提交于 2020-01-15 11:17:32
问题 I'm currently running 2 for-loops, going through 2 arrays of objects and creating a new array with the objects which occur in both lists. When the lists become to large, I get a "Stop running script" prompt. MineGlobals.receivedData = jQuery.parseJSON(MineGlobals.receivedDataRaw); MineGlobals.nettStasjonsListe = new Array(); var len1 = MineGlobals.nsData.length; var len2 = MineGlobals.receivedData.Nettstasjoner.length for (var i = 0; i < len2; i++) { for (var j = 0; j < len1; j++) { if

Javascript: using setTimeout with window.close() not work after using setTimeout with window.open()

自古美人都是妖i 提交于 2020-01-14 10:13:17
问题 I have two setTimeout after another. One to open a webpage in the window and another to close the window after a predetermine amount of time. However, after using setTimeout to open a webpage, the next setTimeout that close the window does not work. The setTimeout with windows.close by itself works fine. I and trying to opening a window with a message; then open a website in the window after a predetermine amount of time, and then close the window after a couple of more seconds has passed.

Javascript: using setTimeout with window.close() not work after using setTimeout with window.open()

落花浮王杯 提交于 2020-01-14 10:11:10
问题 I have two setTimeout after another. One to open a webpage in the window and another to close the window after a predetermine amount of time. However, after using setTimeout to open a webpage, the next setTimeout that close the window does not work. The setTimeout with windows.close by itself works fine. I and trying to opening a window with a message; then open a website in the window after a predetermine amount of time, and then close the window after a couple of more seconds has passed.