Skip to content

Commit 0f497e5

Browse files
committed
Use window.requestAnimationFrame w/o fallback
https://caniuse.com/requestanimationframe
1 parent ff7a10c commit 0f497e5

8 files changed

Lines changed: 9 additions & 32 deletions

File tree

assets/javascripts/lib/util.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,6 @@ let smoothScroll =
379379
null);
380380

381381
$.smoothScroll = function (el, end) {
382-
if (!window.requestAnimationFrame) {
383-
el.scrollTop = end;
384-
return;
385-
}
386-
387382
smoothEnd = end;
388383

389384
if (smoothScroll) {
@@ -472,22 +467,6 @@ $.classify = function (string) {
472467
return string.join("");
473468
};
474469

475-
$.framify = function (fn, obj) {
476-
if (window.requestAnimationFrame) {
477-
return (...args) => requestAnimationFrame(fn.bind(obj, ...args));
478-
} else {
479-
return fn;
480-
}
481-
};
482-
483-
$.requestAnimationFrame = function (fn) {
484-
if (window.requestAnimationFrame) {
485-
requestAnimationFrame(fn);
486-
} else {
487-
setTimeout(fn, 0);
488-
}
489-
};
490-
491470
//
492471
// Miscellaneous
493472
//

assets/javascripts/vendor/prism.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,8 @@ var Prism = (function (_self) {
12551255
highlightAutomaticallyCallback,
12561256
);
12571257
} else {
1258-
if (window.requestAnimationFrame) {
1259-
window.requestAnimationFrame(highlightAutomaticallyCallback);
1258+
if (requestAnimationFrame) {
1259+
requestAnimationFrame(highlightAutomaticallyCallback);
12601260
} else {
12611261
window.setTimeout(highlightAutomaticallyCallback, 16);
12621262
}

assets/javascripts/vendor/raven.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@
12901290

12911291
fill(_window, "setTimeout", wrapTimeFn, wrappedBuiltIns);
12921292
fill(_window, "setInterval", wrapTimeFn, wrappedBuiltIns);
1293-
if (_window.requestAnimationFrame) {
1293+
if (_requestAnimationFrame) {
12941294
fill(
12951295
_window,
12961296
"requestAnimationFrame",

assets/javascripts/views/list/list_focus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ app.views.ListFocus = class ListFocus extends app.View {
1414

1515
constructor(el) {
1616
super(el);
17-
this.focusOnNextFrame = $.framify(this.focus, this);
17+
this.focusOnNextFrame = (el) => requestAnimationFrame(() => this.focus(el));
1818
}
1919

2020
focus(el, options) {

assets/javascripts/views/pages/base.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ app.views.BasePage = class BasePage extends app.View {
2828
this.delay(this.afterRender);
2929
}
3030
if (this.highlightNodes.length > 0) {
31-
$.requestAnimationFrame(() =>
32-
$.requestAnimationFrame(() => this.paintCode()),
33-
);
31+
requestAnimationFrame(() => this.paintCode());
3432
}
3533
}
3634

@@ -68,7 +66,7 @@ app.views.BasePage = class BasePage extends app.View {
6866
}
6967

7068
if (this.highlightNodes.length > 0) {
71-
$.requestAnimationFrame(() => this.paintCode());
69+
requestAnimationFrame(() => this.paintCode());
7270
}
7371
this.previousTiming = timing;
7472
}

assets/javascripts/views/search/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ app.views.Search = class Search extends app.View {
203203
if (context.hash) {
204204
this.delay(this.searchUrl);
205205
}
206-
$.requestAnimationFrame(() => this.autoFocus());
206+
requestAnimationFrame(() => this.autoFocus());
207207
}
208208

209209
extractHashValue() {

assets/javascripts/views/sidebar/doc_picker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ app.views.DocPicker = class DocPicker extends app.View {
5050

5151
this.html(html + this.tmpl("docPickerNote"));
5252

53-
$.requestAnimationFrame(() => this.findByTag("input")?.focus());
53+
requestAnimationFrame(() => this.findByTag("input")?.focus());
5454
}
5555

5656
renderVersions(docs) {

assets/javascripts/views/sidebar/sidebar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ app.views.Sidebar = class Sidebar extends app.View {
6464

6565
resetHoverOnMouseMove() {
6666
$.off(window, "mousemove", this.resetHoverOnMouseMove);
67-
return $.requestAnimationFrame(() => this.resetHover());
67+
return requestAnimationFrame(() => this.resetHover());
6868
}
6969

7070
resetHover() {

0 commit comments

Comments
 (0)