Speed up search and sidebar rendering using requestAnimationFrame

This commit is contained in:
Thibaut Courouble 2016-06-11 11:05:41 -04:00
parent 39cc1d3cba
commit b944227f95
2 changed files with 9 additions and 1 deletions

View file

@ -278,6 +278,12 @@ $.classify = (string) ->
string[i] = substr[0].toUpperCase() + substr[1..]
string.join('')
$.framify = (fn, obj) ->
if requestAnimationFrame
(args...) -> requestAnimationFrame(fn.bind(obj, args...))
else
fn
#
# Miscellaneous
#

View file

@ -12,7 +12,9 @@ class app.views.ListFocus extends app.View
superEnter: 'onSuperEnter'
escape: 'blur'
constructor: (@el) -> super
constructor: (@el) ->
super
@focus = $.framify(@focus, @)
focus: (el) ->
if el and not el.classList.contains @constructor.activeClass