-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,10 @@ var config = require('./config'), | |
join = [].join, | ||
win = window, | ||
console = win.console, | ||
|
||
timeout = win.setTimeout, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yyx990803
Author
Member
|
||
hasClassList = 'classList' in document.documentElement, | ||
ViewModel // late def | ||
|
||
var defer = | ||
win.requestAnimationFrame || | ||
win.webkitRequestAnimationFrame || | ||
win.setTimeout | ||
|
||
var utils = module.exports = { | ||
|
||
/** | ||
|
@@ -195,7 +190,7 @@ var utils = module.exports = { | |
* used to defer batch updates | ||
*/ | ||
nextTick: function (cb) { | ||
defer(cb, 0) | ||
timeout(cb, 0) | ||
}, | ||
|
||
/** | ||
|
3 comments
on commit 5100f3e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a change that should be reverted.
I may be way off base, and if so I apologize, but my understanding is:
setTimeout will fire at a given time based on the interval set, but takes no consideration as to where in the run loop the browser currently is.
rAF on the other hand fires at the beginning of every frame in sync with the run loop so you are guaranteed not to be running computation at a time that may eat into your page paint.
Jank happens when your code is running over the buffer allotted and starts to eat into the time the browser is trying to paint.
Basically your code will run "faster" in that it will not be burdened by the render cycle, but to an end user they will see less fluid updates because it is not able to repaint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dam, I think you are right. I've also later found out that setTimeout
appeared faster in the bench because the bench code clocked everything with setTimeout
itself, and some non-javascript render time was not included in the time measured.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yyx990803 So glad I wasn't out of line there. I only mentioned it because I really like VUE. Would be interesting to profile the TODO apps with something that takes this into account. I've found that once animations are added this tiny change makes a pretty significant difference to the end result being jank free.
There is also
window.setImmediate(f)
, which is only supported in Firefox and IE at the moment. Maybe this line could be replaced by:A strong polyfill here (with IE6-8 and NodeJS parts): https://github.com/NobleJS/setImmediate
Edit: it would be stupid to put
win.setImmediate
in a timeout var, but you get the idea :-)