https://caniuse.com/requestanimationframe
Unified · Split
| @@ -379,11 +379,6 @@ let smoothScroll = · 378 unmodified lines | |||
| 379 | null); | 379 | null); |
| 380 | 380 | ||
| 381 | $.smoothScroll = function (el, end) { | 381 | $.smoothScroll = function (el, end) { |
| 382 | if (!window.requestAnimationFrame) { | ||
| 383 | el.scrollTop = end; | ||
| 384 | return; | ||
| 385 | } | ||
| 386 | |||
| 387 | smoothEnd = end; | 382 | smoothEnd = end; |
| 388 | 383 | ||
| 389 | if (smoothScroll) { | 384 | if (smoothScroll) { |
| @@ -472,22 +467,6 @@ $.classify = function (string) { · 82 unmodified lines | |||
| 472 | return string.join(""); | 467 | return string.join(""); |
| 473 | }; | 468 | }; |
| 474 | 469 | ||
| 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 | |||
| 491 | // | 470 | // |
| 492 | // Miscellaneous | 471 | // Miscellaneous |
| 493 | // | 472 | // |
| @@ -1255,8 +1255,8 @@ var Prism = (function (_self) { · 1254 unmodified lines | |||
| 1255 | highlightAutomaticallyCallback, | 1255 | highlightAutomaticallyCallback, |
| 1256 | ); | 1256 | ); |
| 1257 | } else { | 1257 | } else { |
| 1258 | if (window.requestAnimationFrame) { | 1258 | if (requestAnimationFrame) { |
| 1259 | window.requestAnimationFrame(highlightAutomaticallyCallback); | 1259 | requestAnimationFrame(highlightAutomaticallyCallback); |
| 1260 | } else { | 1260 | } else { |
| 1261 | window.setTimeout(highlightAutomaticallyCallback, 16); | 1261 | window.setTimeout(highlightAutomaticallyCallback, 16); |
| 1262 | } | 1262 | } |
| @@ -1290,7 +1290,7 @@ · 1289 unmodified lines | |||
| 1290 | 1290 | ||
| 1291 | fill(_window, "setTimeout", wrapTimeFn, wrappedBuiltIns); | 1291 | fill(_window, "setTimeout", wrapTimeFn, wrappedBuiltIns); |
| 1292 | fill(_window, "setInterval", wrapTimeFn, wrappedBuiltIns); | 1292 | fill(_window, "setInterval", wrapTimeFn, wrappedBuiltIns); |
| 1293 | if (_window.requestAnimationFrame) { | 1293 | if (_requestAnimationFrame) { |
| 1294 | fill( | 1294 | fill( |
| 1295 | _window, | 1295 | _window, |
| 1296 | "requestAnimationFrame", | 1296 | "requestAnimationFrame", |
| @@ -14,7 +14,7 @@ app.views.ListFocus = class ListFocus extends app.View { · 13 unmodified lines | |||
| 14 | 14 | ||
| 15 | constructor(el) { | 15 | constructor(el) { |
| 16 | super(el); | 16 | super(el); |
| 17 | this.focusOnNextFrame = $.framify(this.focus, this); | 17 | this.focusOnNextFrame = (el) => requestAnimationFrame(() => this.focus(el)); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | focus(el, options) { | 20 | focus(el, options) { |
| @@ -28,9 +28,7 @@ app.views.BasePage = class BasePage extends app.View { · 27 unmodified lines | |||
| 28 | this.delay(this.afterRender); | 28 | this.delay(this.afterRender); |
| 29 | } | 29 | } |
| 30 | if (this.highlightNodes.length > 0) { | 30 | if (this.highlightNodes.length > 0) { |
| 31 | $.requestAnimationFrame(() => | 31 | requestAnimationFrame(() => this.paintCode()); |
| 32 | $.requestAnimationFrame(() => this.paintCode()), | ||
| 33 | ); | ||
| 34 | } | 32 | } |
| 35 | } | 33 | } |
| 36 | 34 | ||
| @@ -68,7 +66,7 @@ app.views.BasePage = class BasePage extends app.View { · 31 unmodified lines | |||
| 68 | } | 66 | } |
| 69 | 67 | ||
| 70 | if (this.highlightNodes.length > 0) { | 68 | if (this.highlightNodes.length > 0) { |
| 71 | $.requestAnimationFrame(() => this.paintCode()); | 69 | requestAnimationFrame(() => this.paintCode()); |
| 72 | } | 70 | } |
| 73 | this.previousTiming = timing; | 71 | this.previousTiming = timing; |
| 74 | } | 72 | } |
| @@ -203,7 +203,7 @@ app.views.Search = class Search extends app.View { · 202 unmodified lines | |||
| 203 | if (context.hash) { | 203 | if (context.hash) { |
| 204 | this.delay(this.searchUrl); | 204 | this.delay(this.searchUrl); |
| 205 | } | 205 | } |
| 206 | $.requestAnimationFrame(() => this.autoFocus()); | 206 | requestAnimationFrame(() => this.autoFocus()); |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | extractHashValue() { | 209 | extractHashValue() { |
| @@ -50,7 +50,7 @@ app.views.DocPicker = class DocPicker extends app.View { · 49 unmodified lines | |||
| 50 | 50 | ||
| 51 | this.html(html + this.tmpl("docPickerNote")); | 51 | this.html(html + this.tmpl("docPickerNote")); |
| 52 | 52 | ||
| 53 | $.requestAnimationFrame(() => this.findByTag("input")?.focus()); | 53 | requestAnimationFrame(() => this.findByTag("input")?.focus()); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | renderVersions(docs) { | 56 | renderVersions(docs) { |
| @@ -64,7 +64,7 @@ app.views.Sidebar = class Sidebar extends app.View { · 63 unmodified lines | |||
| 64 | 64 | ||
| 65 | resetHoverOnMouseMove() { | 65 | resetHoverOnMouseMove() { |
| 66 | $.off(window, "mousemove", this.resetHoverOnMouseMove); | 66 | $.off(window, "mousemove", this.resetHoverOnMouseMove); |
| 67 | return $.requestAnimationFrame(() => this.resetHover()); | 67 | return requestAnimationFrame(() => this.resetHover()); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | resetHover() { | 70 | resetHover() { |