Questions tagged [cleartimeout]

159 questions
8
votes
2 answers

How to clear a settimeout in react

On each question component, I am trying to clear the time out. So on componentWillMount() I will start the timer and then on componentDidUpdate() I will clear the timeout. The timer does not seem to be working.After the timer expires I will push the…
jdip88
  • 387
  • 1
  • 6
  • 17
8
votes
2 answers

how to clear all javascript Timeouts?

i have a loop function that in first 5 seconds it runs social1() and in second 5 seconds it runs social2() then loop ... i have 2 hover functions too i need clear all active timeouts because when i hover on images (.social1 & .social2), i can see…
Mohammad Masoudian
  • 3,370
  • 7
  • 23
  • 40
6
votes
3 answers

Why is clearTimeout not clearing the timeout in this react component?

I am attempting to clear a former timeout before initiating a new timeout, because I want messages to display for 4 seconds and disappear UNLESS a new message pops up before the 4 seconds is up. The Problem: Old timeouts are clearing the current…
Gabriel Kunkel
  • 2,211
  • 3
  • 20
  • 35
6
votes
2 answers

How to clearTimeout an async function when componentWillUnmount in a Reactjs component?

Here is the component: class ChartComp extends Component{ constructor(props){ super(props); this.timer = null; this.loadData = this.loadData.bind(this); } componentWillMount(){ this.loadData(); } …
Cinque
  • 115
  • 1
  • 1
  • 4
4
votes
1 answer

How to check if clearTimeout was called with sinon.useFakeTimers?

I'm using sinon with fake timers and I want to check if clearTimeout was called with a specific timeout-id. var clock = sinon.useFakeTimers(); functionUnderTest(); // How can I know if functionUnderTest cleared a specific timeout?
Motti
  • 99,411
  • 44
  • 178
  • 249
4
votes
2 answers

How to pause a function in JavaScript?

I have a long function in JavaScript and I am going to pause it at some points. I know that I can do that using setTimeout(myFunction, 100) and clearTimeout(). But, as I know, after using setTimeout(myFunction, 100) my function would be executed…
Suo6613
  • 431
  • 4
  • 15
4
votes
1 answer

clearTimeout() for setTimeout() in for loop

clearTimeout() inside for loop doesn't work for(i=0;i<10;i++){ myVar = setTimeout(function(){ alert("Hello") }, 3000); } Fiddle : not working Fiddle : working Please help me to stop setTimeout() in first Fiddle.
user3941922
4
votes
2 answers

Javascript: unable to clearTimeout

I'm trying to call a function after a short delay after a user stops typing, but clearTimeout() does not seem to be doing what I think. The following is inside an Angular JS controller. $scope.typing = false; $scope.delay = undefined; //Triggered…
emersonthis
  • 30,934
  • 52
  • 191
  • 328
3
votes
1 answer

JS clear timer of previous function call before new function call

My React app uses a slider component from Material UI. Its onChange event calls a function to update the state. I realized that my component rerenders for every slider step which is why I want to delay the updating of the state for like 300ms after…
Rtholl
  • 53
  • 4
3
votes
2 answers

Timer keeps getting faster on every reset

The timer keeps getting faster every time I reset it. I'm thinking I need to use clearTimeout but am unsure about how to implement it. Here's the code: $(function(){ sessionmin = 25; $("#sessionMinutes").html(sessionmin); …
bradley
  • 33
  • 5
3
votes
3 answers

Reset Timeout of the same timer in a for loop in Javascript

I guess that this could be a duplicate because of the simple nature of the question, but I could not find any answer. I am setting a Timeout function in a foor loop if a certain condition is true. As I don't want to declare the Timeout within the…
Merc
  • 3,105
  • 5
  • 39
  • 70
3
votes
1 answer

setTimeout still fires despite clearTimeout

I have the following function. The intent is that when you hover over an item with the class .toolTip, it'll log the data-tooltip from the element you're hovering over after 3 seconds. However, if your cursor leaves the item, it should cancel the…
Sinister Beard
  • 3,615
  • 10
  • 53
  • 90
3
votes
2 answers

JS - how to remove setTimeOut for my code

I am trying to use vertical scroll to display an object A. The idea is that if my scroll height is greater than scrollHeight (15), then after 1.2 second, A will show up. Then when I scroll back to top, A will hide. The problem right now is that if…
fuyiii
  • 33
  • 4
3
votes
1 answer

What is the "cleartimeout" equivalent for Swift?

I'm trying to set up a timeout on a text input field that only implements the inner code a second after the user stops typing. So while the user is typing, I would continually call a cleartimeout and re-initiate the setTimeout. I was originally…
mike
  • 152
  • 3
  • 10
3
votes
2 answers

Javascript: SetTimeout and ClearTimeout reset.

I have this following session time javascript code