Skip to content

Commit

Permalink
fix regression introduced in #22
Browse files Browse the repository at this point in the history
  • Loading branch information
zspecza committed Nov 16, 2016
1 parent 5418e84 commit d542b60
Showing 1 changed file with 7 additions and 4 deletions.
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

0 comments on commit d542b60

Please sign in to comment.