Use window.requestAnimationFrame w/o fallback

https://caniuse.com/requestanimationframe
pull/1441/head
Simon Legner 1 year ago
parent ff7a10c003
commit 0f497e57c8

@ -379,11 +379,6 @@ let smoothScroll =
null);
$.smoothScroll = function (el, end) {
if (!window.requestAnimationFrame) {
el.scrollTop = end;
return;
}
smoothEnd = end;
if (smoothScroll) {
@ -472,22 +467,6 @@ $.classify = function (string) {
return string.join("");
};
$.framify = function (fn, obj) {
if (window.requestAnimationFrame) {
return (...args) => requestAnimationFrame(fn.bind(obj, ...args));
} else {
return fn;
}
};
$.requestAnimationFrame = function (fn) {
if (window.requestAnimationFrame) {
requestAnimationFrame(fn);
} else {
setTimeout(fn, 0);
}
};
//
// Miscellaneous
//

@ -1255,8 +1255,8 @@ var Prism = (function (_self) {
highlightAutomaticallyCallback,
);
} else {
if (window.requestAnimationFrame) {
window.requestAnimationFrame(highlightAutomaticallyCallback);
if (requestAnimationFrame) {
requestAnimationFrame(highlightAutomaticallyCallback);
} else {
window.setTimeout(highlightAutomaticallyCallback, 16);
}

@ -1290,7 +1290,7 @@
fill(_window, "setTimeout", wrapTimeFn, wrappedBuiltIns);
fill(_window, "setInterval", wrapTimeFn, wrappedBuiltIns);
if (_window.requestAnimationFrame) {
if (_requestAnimationFrame) {
fill(
_window,
"requestAnimationFrame",

@ -14,7 +14,7 @@ app.views.ListFocus = class ListFocus extends app.View {
constructor(el) {
super(el);
this.focusOnNextFrame = $.framify(this.focus, this);
this.focusOnNextFrame = (el) => requestAnimationFrame(() => this.focus(el));
}
focus(el, options) {

@ -28,9 +28,7 @@ app.views.BasePage = class BasePage extends app.View {
this.delay(this.afterRender);
}
if (this.highlightNodes.length > 0) {
$.requestAnimationFrame(() =>
$.requestAnimationFrame(() => this.paintCode()),
);
requestAnimationFrame(() => this.paintCode());
}
}
@ -68,7 +66,7 @@ app.views.BasePage = class BasePage extends app.View {
}
if (this.highlightNodes.length > 0) {
$.requestAnimationFrame(() => this.paintCode());
requestAnimationFrame(() => this.paintCode());
}
this.previousTiming = timing;
}

@ -203,7 +203,7 @@ app.views.Search = class Search extends app.View {
if (context.hash) {
this.delay(this.searchUrl);
}
$.requestAnimationFrame(() => this.autoFocus());
requestAnimationFrame(() => this.autoFocus());
}
extractHashValue() {

@ -50,7 +50,7 @@ app.views.DocPicker = class DocPicker extends app.View {
this.html(html + this.tmpl("docPickerNote"));
$.requestAnimationFrame(() => this.findByTag("input")?.focus());
requestAnimationFrame(() => this.findByTag("input")?.focus());
}
renderVersions(docs) {

@ -64,7 +64,7 @@ app.views.Sidebar = class Sidebar extends app.View {
resetHoverOnMouseMove() {
$.off(window, "mousemove", this.resetHoverOnMouseMove);
return $.requestAnimationFrame(() => this.resetHover());
return requestAnimationFrame(() => this.resetHover());
}
resetHover() {

Loading…
Cancel
Save