Questions tagged [settimeout]

setTimeout is a global JavaScript method, used to execute a particular function or piece of code after a given delay.

Filter by
Sorted by
Tagged with
0 votes
1 answer
36 views

Parallax effect and delay with Canvas - images loaded with JavaScript

With Canvas, I work on a parallax effect with images loaded into the main.js file. Parallax works fine The draft code is here: https://github.com/bengabo/parallax-image My problem is that I want to ...
bengabo's user avatar
  • 55
-1 votes
1 answer
41 views

Periodically calling a function, stack growing indefinite

I have the following JavaScript code and noticed the stack is growing indefinitely. https://jsfiddle.net/uok7vz9b/ (function () { async function poll() { try { // await fetch ... } ...
Micha's user avatar
  • 355
-1 votes
1 answer
34 views

SetTimeout () in javascript

What is the point of giving the time duation in setTimeout() function ? Altough the callback will have to wait for the call stack to be completely empty. For example if i write this code. setTimeout(()...
Chinmay Behera's user avatar
-2 votes
1 answer
46 views

setTimout has no delay even though there are no obvious errors [duplicate]

function abc() { console.log("ok") } setTimeout(abc, 10000000000000000000000000000000) When I run this code, it should delay the printing of ok by 10000000000000000000000000000000ms, but it ...
doctor industries's user avatar
0 votes
0 answers
13 views

timer is not getting latest state in react [progress bar in react]

Hey I have created this progress bar. The timer inside of useEffect which increases 10% of progress after 1 sec is not getting latest state. You can simulate that by frquenty clicking the reset button....
Laxmi Prasanna Rokkam's user avatar
0 votes
1 answer
29 views

Unexpected behavior when using setInterval function in React useEffect [duplicate]

UPDATE - None of the responses to the duplicated questions provide an explanation for how the line return () => { clearInterval(id); }; resolves the issue. Instead, they simply suggest removing the ...
omar's user avatar
  • 500
-1 votes
0 answers
31 views

I'm trying to use setTimeout in my tester file and connect it to my HTML file [closed]

<!-- app.component.html --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=...
AyushmaanKarn's user avatar
-1 votes
1 answer
51 views

Javascript setTimeOut unaccuracy, weird behaviour

I need to time something kinda precise in the browser console. It sends a request to another website thats using pool.ntp.org to sync the own time. It would be good if its +-50ms. I know that I have ...
Introser's user avatar
  • 159
0 votes
1 answer
25 views

TypeError: setTimeout is not a function

I'm trying to implement a setTimeout() on my node.js application, but I can't make it work. I'm first trying with a simple snippet but still, not working. Please see the code snippet bellow: ...
GP.'s user avatar
  • 1
0 votes
0 answers
28 views

How i can get rerurn by Timeout? Or how abort function run with Timeout [duplicate]

I need to abort or return from a function before it completes on its own. I have tried this, but it returns 100 async function Later() { setTimeout(() => { return 10 }, 1_000) await new ...
ObscuRUS's user avatar
-1 votes
1 answer
51 views

Is setTimeout() a higher order function?

A higher order function is a function which takes one or more functions as arguments and/or returns a function as a result. I have read on various sources online that setTimeout() is a HOF but ChatGPT ...
Lokesh Kumar's user avatar
1 vote
1 answer
20 views

How do I make text flash that's already inside a setInterval + loop

I have a script for reply times in a queue system. I would like the text that gets highlighted red/orange to flash. I am unsure how to do this as it's already inside a setInterval block that also ...
Joe's user avatar
  • 11
-1 votes
1 answer
24 views

Send property as argument in function

I have a bootstrap alert that is being called a few different times so I want write a function to reuse. I want the alert to disappear after 3 seconds and also do something. So in my setTimeout I want ...
nb_nb_nb's user avatar
  • 1,257
0 votes
0 answers
21 views

Nextjs - Adding a index.html page to static export

I have a code for this API to Replicate AI models. The problem is that some modules a long time to get the answer from API, the longest I had was 200s. But of course the request crashes before the ...
Assaf Sela's user avatar
0 votes
0 answers
30 views

Concerned about Stack with nested setTimeout in Javascript [duplicate]

I have a frequently-firing event in Javascript. Although it is called roughly once-per-second, variations in timing mean I can't use setInterval and instead have a setTimeout function. It's 'recursive'...
Steve Harding's user avatar
-1 votes
0 answers
20 views

How can I run a function every second with high accuracy in JavaScript without setInterval or setTimeout?

I need to execute a function every second in JavaScript with the highest possible accuracy. I've noticed that setInterval and setTimeout can sometimes be imprecise due to variations in the JavaScript ...
Collo Stinga's user avatar
-1 votes
1 answer
62 views

Why is clearTimeout not clearing the timer?

The code below listens for the users internet connection going offline/online: let timer; window.onoffline = () => { console.log('offline!'); console.log('clearing timeout'); if (timer) { ...
Mike Rifgin's user avatar
  • 10.4k
2 votes
1 answer
55 views

displaying message with setTimeOut and clearTimeout

I am working on a credit card checker project. The validation code works (so I don't include the code for it) but I want to go a step further: the user types in a number and gets a reply. If the card ...
Veelcheck's user avatar
0 votes
1 answer
77 views

setTimout method not working not exucting as many times as it should

I am trying to create a cool little visual of how Dijkstra's algorithm works on a grid. The user is supposed to click on two tiles and then it should show you all the tiles that have been searched. At ...
someCoder21's user avatar
2 votes
2 answers
77 views

Is there a reference clock for JavaScript's setTimeout

As far as I understand it, setTimeout(code, delay) will call a callback at the current time plus delay. Is there a reference clock for when the delay has expired? I.e. if I were to change the ...
sudo rm -rf slash's user avatar
0 votes
0 answers
31 views

Accurate timer with javascript

I'm trying to build an accurate timer with javascript. My first try was using setInterval(), and of course it was a disaster. Then I tried to use requestAnimationFrame(), with the following code: ...
jeansvf's user avatar
  • 13
-1 votes
0 answers
23 views

Why This for Loop Is not following the constrain which is i<=5? [duplicate]

function x(){ for(var i=1; i<=5; i++){ setTimeout( function(){ console.log(i); }, i * 1000 ); } } x(); so I was ...
Sagar Baryekar's user avatar
0 votes
2 answers
65 views

how to run a Promise in async function more than once?

I'm learning promise and async await, here I want to call addPost function and push an object twice and then I want to loop on that array of objects to see the results, but in this code the result is ...
Rishabh Sharma's user avatar
0 votes
1 answer
23 views

Make a ErrorMessage desappear using Formik and Yup

I would like to inquire if it's possible to make an ErrorMessage component disappear after a certain period of time. I've been attempting to achieve this using setTimeout, but unfortunately, it doesn'...
Gerardo J. Cruz's user avatar
0 votes
1 answer
22 views

setTimeout makes the text unidentified

I want to write a code that accepts my string and display it after 4 seconds I wrote this code to show hi after 4 seconds but instea,d it shows the string right away and after 4 seconds it becomes ...
Ashir Nadeem's user avatar
1 vote
1 answer
64 views

How to call a function after CSS transition is finished - React

I have a React app that has a grid of cards. I added some javascript along with CSS transitions to animate the card flipping. When clicked, the card will flip to the back, wait 2 seconds then ...
Bruno Oliveira's user avatar
1 vote
2 answers
61 views

When does re-rendering actually happens?

Code: import { useState } from 'react'; export default function Counter() { const [number, setNumber] = useState(0); return ( <> <h1>{number}</h1> <button ...
cheems's user avatar
  • 164
0 votes
1 answer
41 views

Oberver.next() is not a function

I want to print hello world const obs = new Observable( (observer)=>{ setTimeout(observer.next, 0) } ); obs.subscribe(()=>{console.log("world")}); console.log("hello "); ...
Urooj's user avatar
  • 323
0 votes
0 answers
22 views

Jquery setTimeout up my CPU when click for load [duplicate]

This question is not a duplicate of what they put there, moreover it has nothing to do with it since my question is about the possible causes of the cpu firing with the normal onclick event, because ...
Jean's user avatar
  • 13
0 votes
0 answers
22 views

How to add two second hold time to hover action berfore it activates in pinia store with vuejs

So I'm making a website for online store with item cards. I want to expand the card with more info and detailed description when the user hovers on it for 1.5sec - 2secs. I first implented it to every ...
Angel's user avatar
  • 1
-1 votes
2 answers
38 views

useEffect calling function even if input is not changed [closed]

Home.js export default function Home({ movies }) { const [searchTerm, setSearchTerm] = useState(""); const [inputChanged, setInputChanged] = useState(false); const [loading, setLoading]...
Shubham Singhvi's user avatar
0 votes
0 answers
13 views

react-spring: execute callback after 1st rest only

I have the following looping spring const [swipeSpring, _] = useSpring(() => { return { from: { backgroundPosition: '0 0' }, to: { backgroundPosition: reducedMotion ? '0 0' : '115%...
Aaron Parisi's user avatar
0 votes
0 answers
9 views

setTimeout values inside for loop in javascript [duplicate]

why it is printing 11 eleven times?this code is printing 0,1,2,3,4 ....10, while i is declared using let. But why it is printing 11 while i is decalred using var. why it is printing 11 inside ...
Rahul Biswal's user avatar
0 votes
2 answers
49 views

JavaScript timeout() not working properly

I'm continuing with learning javascript and I've come across this problem //let startTime=NaN; document.getElementById( "start_button").addEventListener( 'click',()=>{ ...
MAXWEL OMONDI's user avatar
0 votes
3 answers
44 views

Got a little issue with setTimeout in Javascript - it isnt properly working

So I have a checkbox. And I am trying to make it so that when you click the checkbox, it shows a message, pauses, and then does another thing. I know you can use setInterval or setTimeout - I am using ...
CoderMan's user avatar
2 votes
0 answers
44 views

swift DispatchQueue.main.asyncAfter doesn't work in command line? [duplicate]

import Foundation import Dispatch DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { print("fffffff") } run by swift but program ends without output:
eczn's user avatar
  • 1,469
0 votes
0 answers
8 views

JS using setTimeout and calling set of functions afterwards - DIVI in Wordpress

I'm working on this site using DIVI Framework. The main page has a form that sends to a thank you page, and is what I need help: I need to set a timeout to send the user to a list of Whatsapp groups ...
Erik eDragon's user avatar
1 vote
1 answer
43 views

what would happen if I use thousands of setTimeouts? [closed]

a have a site that is server-sided through node.js, it generates a new code each time you refresh the page, I want to detect if 24h has passed since the last code generation, problem is that for me to ...
KILLXR's user avatar
  • 23
1 vote
1 answer
37 views

JavaScript setTimeout() and setInterval() glitching after a min

HTML Code: <div class="container"> <div> <h1 class="scrambleanimation">Creative Agency</h1> <h1 class="scrambleanimation"&...
muzzammil professionaltech's user avatar
0 votes
3 answers
59 views

setTimeout function does not function as expected

I am writing a function which resizes the window using window.ResizeBy 5 seconds after the page loads using setTimeout. The setTimeout function is supposed to delay the function by five seconds, yet ...
BeginnerCoder1992's user avatar
0 votes
0 answers
61 views

Flow of execution inside a promise

I've the below piece of code and want to understand how event loop, macro-task queue and micro-task queue come into picture. I've recently started learning about the above concepts so let me me know ...
Ajay Negi's user avatar
1 vote
1 answer
54 views

Is it safe to set many Timeouts in JavaScript (NodeJS, ExpressJS)?

I've developed a Cache service with JavaScript (in NodeJS, via TypeScript) which one can set an "expiry" for an item (like Redis). to "expire" an item at desired time, "...
Ali Fathi  's user avatar
0 votes
1 answer
54 views

Why ngDoCheck is called when setTimeout is resolved?

I'm trying to understand why ngDoCheck runs when setTimeout is resolved. I've a simple component like this. @Component({ selector: 'app-child', templateUrl: './child.component.html', styleUrls: [...
Waleed Ahmad's user avatar
0 votes
2 answers
45 views

setTimeout with text AND <img src>? getting [object Object]

Im trying to set useState/timeout to display text and an icon image after 5 seconds, text is fine but i want to be able to also have an image: import slackbot from '../../public/images/slackbot.png' ...
Tayla's user avatar
  • 3
1 vote
1 answer
30 views

clearTimout reference before initialization

I need to clear this timeout before running the next. But how do i do that with the scope issue? function splashHandler() { clearTimeout(splashTimeout); // <--can't call before initialization... ...
lache's user avatar
  • 608
0 votes
1 answer
40 views

Play a video source, after setTimeout function is done

I would like to show a splash image over top of an HTML Video for about 3 seconds. My thought is to have the splash image show initially, then a use setTimeout function to turn the splash image off ...
lache's user avatar
  • 608
0 votes
1 answer
41 views

Best approach to game loop timer in typescript with no animation

Suppose I have a react native typescript app, and I have a class Game that has a method startTimer(). When startTimer is called, it need to start running a game loop, which means it needs to call the ...
Marc's user avatar
  • 3,416
0 votes
1 answer
32 views

How to close triggered popup function in SetTimeout?

I am customizing the code for a UNA CMS community site that uses PHP, JavaScript, jQuery, XML, etc. UNA has a unique problem in that you can attach link data using iFramely but the video thumbnail ...
JustAnotherCoder's user avatar
0 votes
1 answer
20 views

How to set timer, for example 01:24:40:15 (dd HH:mm:ss) format in Angular 11,12,13,14 etc and javascript

Want to set Time in dd HH:mm:ss format
The Losers Club's user avatar
2 votes
3 answers
45 views

Javascript/jQuery I can't stop time with setTimeout, error find variable

I use setTimeout to create a time countdown of 5 seconds (it works), but I want to stop the setTimeout with Button Stop, but I have an error finding the variable. What is the error? function ...
Renato Ramos Puma's user avatar

1
2 3 4 5
107