Skip to content
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

Fixed unreliability on setTimeOut #15

Open
wants to merge 6 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/jquery-backward-timer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/jquery-backward-timer.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
, plugin = this

plugin.seconds_left = 0
plugin.final_hour = Math.floor(Date.now()) + 5
plugin.target = $(element)
plugin.timeout = undefined
plugin.settings = {}
Expand Down Expand Up @@ -71,6 +72,7 @@
}
}
, reset: function() {
plugin.final_hour = parseInt(plugin.settings.seconds) + Math.floor(Date.now()/1000)
plugin.seconds_left = plugin.settings.seconds
plugin.methods._render_seconds()
}
Expand All @@ -94,7 +96,7 @@
var step = plugin.settings.step
}

plugin.seconds_left -= step
plugin.seconds_left = (plugin.final_hour - Math.floor(Date.now()/1000))

var interval = step * 1000
plugin.timeout = setTimeout(plugin.methods._on_tick,
Expand Down