Skip to content

Commit

Permalink
rollup requestAnimationFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
yisar committed Dec 31, 2019
1 parent 851eaf7 commit efc9dc3
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,9 @@ function flushWork() {

export const planWork = (() => {
if (typeof MessageChannel !== 'undefined') {
const channel = new MessageChannel()
return cb => {
if (cb) {
channel.port2.onmessage = cb
channel.port1.postMessage(null)
} else {
channel.port1.onmessage = flushWork
channel.port2.postMessage(null)
}
}
const { port1, port2 } = new MessageChannel()
port1.onmessage = flushWork
return cb => (cb ? requestAnimationFrame(cb) : port2.postMessage(null))
}
return cb => setTimeout(cb || flushWork)
})()
Expand Down

0 comments on commit efc9dc3

Please sign in to comment.