-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pause functionality not working for all timers #73
Comments
@wgpalexander Secondly, I d like some more info so that I can set up a local representation of this issue you are facing. To get some context, is it like you want something to be done for say 1 minute (TotalTime) and then Also, do you have a JavaScript At this moment I m not sure if this is a plugin issue or not, but whatever it is, we ll fix it :) |
Hi walmik - thanks for the prompt response. In summary - I am looking to time a series of workout intervals, the sum of which is a total workout. I want to show the user
Consider this example - I want to do as many chin ups as I can in 3 minutes, then rest for 1 minute before another session of 3 minutes work. That is 3 intervals. REMAINING would be set to 7 mins (3+1+3) and would count down to 4 mins over the first interval. After 3 minutes I have coded that the ELAPSED timer is removed & replaced with another ELAPSED timer with the new interval (all this works already so no worries here) and the next interval of 1 minute counts up without intervention. Again for the final interval the ELAPSED counter is removed & replaced with another 3 minute one which starts counting up immediately While hopefully this background helps, the issue seems to be with the pause mechanics within the script. When I run my app without pausing all the timers count up/down as required and work perfectly. When I pause & then resume they seem to go out of sync. I'm not using setInterval. Thanks again! |
HI Wayne! I m sorry I couldnt look into this right away after writing to you as I got real busy at work! Anyway, could you please try something? Please download the latest timer plugin and get hold of any jquery. Basically put these 2 files in a new folder. In the same folder create a new index.html and paste in the following contents. Once you do that, can you please use that as a playground and see if you are facing the same issue?
Lemme know how it goes. |
That script seems to work - I will see if I can somehow use it to amend my existing script & come back to you. |
@walmik - firstly thanks for the continued help with this! As luck would have it I had some time tonight to look at the script. Your one above seems to work. Unfortunately I still cannot get mine to work properly (I will continue to debug using your script when I can get another chance to look at it). I have recreated my issue however in a simple html file so I can share it with you. This has the same issue I have in my main file - see below: ` <title>jQuery timer test</title> <script type="text/javascript" src="jquery.mobile-1.4.5.min.js"></script> <script type="text/javascript" src="jquery-1.12.0.min.js"></script> <script type="text/javascript" src="timer.jquery.min.js"></script>
I'm fairly new to JS and coding in general so go easy on my code ability :) Think it might be something in the resume element of the "if"... But I could be wrong. |
Hi Wayne, I think I see the problem. The I also feel you may need to really revisit some of this code, especially the cascading startTimers one inside the other. One minor thing I d like to point out is, if you are using all the values in |
Hi walmik, Thanks for the response again. I agree that the coding probably needs revised - I drafted it a while ago and was just looking to prove I could do a series of timers in a row one after the other. Out of interest, how would you execute the same task? Pushing the lazy coding to one side, I added some alerts (in place of console logs) to the script and it does fire the pause/resume commands as far as I can tell. See below code. Would you be able to copy into a new document and see if you get the same issue on your machine? ` <title>jQuery timer test</title> <script type="text/javascript" src="jquery.mobile-1.4.5.min.js"></script> <script type="text/javascript" src="jquery-1.12.0.min.js"></script> <script type="text/javascript" src="timer.jquery.min.js"></script>
|
Walmik - I've played around with the script and got it working. I've simplified the start button to simply kick the timers off and added a separate resume button. This seems to have solved the issue - although I'm unclear why - but I'm happy regardless! Thanks for your help! |
@wgpalexander I ll close this issue for now but do not hesitate to reach out again if you face more issues. If you want we can setup a Google hangout call and I can address/recommend any improvements that I can think of on your project. All free of charge of course. I m just glad you are using the timer plugin for your project and I want to support it :) |
Hi guys,
Firstly - great script, I'm using it within PhoneGap to create my first basic test app and it's proving very useful.
I am creating a simple timer on one screen where we have 3 simultaneous timers:
Lets ignore the complexities around refreshing the Elapsed timer for each interval and getting the total time for the countdown for the moment.
I start all timers simultaneously using $('#Go').click - assuming this is all I do the counters work well.
I have a pause button triggered by $('#Pause').click which then pauses all the timers at whatever reading they were on using the following code:
$('#Pause').click(function() {
// Now need to pause the timers
$('#Elapsed').timer('pause');
$('#TotalTime').timer('pause');
$('#Remaining').timer('pause');
}); // End Pause click
When I resume the timers however Elapsed seems to work as intended, but the other two timers jump out of sync - e.g. I have a demo running in the background just now which is meant to last 30s but TotalTime is 6:55 and Remaining is -7:25.
I tried flashing an alert when paused to confirm the state of the timers and they all do return "paused" as I would expect so I think I'm implementing it properly.
I noted that there was a closed case for a similar issue which you corrected with the latest version - I tried replacing the script with that one but the problem persisted (and actually created a new one whereby there is a slight delay starting the timers which knocks some other stuff out.)
Would you be able to advise whether this is a script issue or a user issue? Would be great to get this resolved as I can finally close off that piece of my app :)
Many thanks
Wayne
The text was updated successfully, but these errors were encountered: