Skip to content

Commit 11f60d7

Browse files
authored
Prefer requestAnimationFrame() over setTimeout() (#1358)
For UI changes that need to delay until the next browser repaint, using requestAnimationFrame() is preferred over using an arbitrary short time with setTimeout(). https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
1 parent e085f00 commit 11f60d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

debug_toolbar/static/debug_toolbar/js/toolbar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ const djdt = {
177177
if (djdt.handleDragged) {
178178
event.preventDefault();
179179
localStorage.setItem("djdt.top", handle.offsetTop);
180-
setTimeout(function () {
180+
requestAnimationFrame(function () {
181181
djdt.handleDragged = false;
182-
}, 10);
182+
});
183183
}
184184
});
185185
const show =

0 commit comments

Comments
 (0)