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

fix regression introduced in #22 #23

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 7 additions & 4 deletions src/client/batchUpdate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// fallback to timers if rAF not present
const stopUpdate = window.cancelAnimationFrame || window.clearTimeout
const startUpdate = window.requestAnimationFrame || ((cb) => window.setTimeout(cb, 0))

/**
* Performs a batched update. Uses requestAnimationFrame to prevent
* calling a function too many times in quick succession.
Expand All @@ -13,7 +9,14 @@ const startUpdate = window.requestAnimationFrame || ((cb) => window.setTimeout(c
* @return {Number} id - a new ID
*/
export default function batchUpdate (id, callback) {
// fallback to timers if rAF not present
const stopUpdate = window.cancelAnimationFrame || window.clearTimeout
const startUpdate = window.requestAnimationFrame || ((cb) => window.setTimeout(cb, 0))

// stop any existing updates
stopUpdate(id)

// perform an update
return startUpdate(() => {
id = null
callback()
Expand Down