Skip to content

Commit

Permalink
Create one-time mouseup listener for each mousedown (#1697)
Browse files Browse the repository at this point in the history
Create mouse up listener for each mouse down
  • Loading branch information
scuml committed Nov 2, 2022
1 parent e5eb6c2 commit 8e3335a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions debug_toolbar/static/debug_toolbar/js/toolbar.js
Expand Up @@ -188,20 +188,25 @@ const djdt = {
startPageY = event.pageY;
baseY = handle.offsetTop - startPageY;
document.addEventListener("mousemove", onHandleMove);

document.addEventListener(
"mouseup",
function (event) {
document.removeEventListener("mousemove", onHandleMove);
if (djdt.handleDragged) {
event.preventDefault();
localStorage.setItem("djdt.top", handle.offsetTop);
requestAnimationFrame(function () {
djdt.handleDragged = false;
});
djdt.ensureHandleVisibility();
}
},
{ once: true }
);
}
);

document.addEventListener("mouseup", function (event) {
document.removeEventListener("mousemove", onHandleMove);
if (djdt.handleDragged) {
event.preventDefault();
localStorage.setItem("djdt.top", handle.offsetTop);
requestAnimationFrame(function () {
djdt.handleDragged = false;
});
djdt.ensureHandleVisibility();
}
});
const djDebug = getDebugElement();
// Make sure the debug element is rendered at least once.
// showToolbar will continue to show it in the future if the
Expand Down

0 comments on commit 8e3335a

Please sign in to comment.