FIX: fix dragging in horizontal overflow component (#20018)

This commit is contained in:
Kris 2023-02-06 09:51:41 -05:00 committed by GitHub
parent 95999c80ce
commit 156e04515f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -78,19 +78,20 @@ export default class HorizontalOverflowNav extends Component {
const mouseDragScroll = function (e) {
let mouseChange = e.clientX - position.x;
navPills.scrollLeft = position.left - mouseChange;
navPills.querySelectorAll("a").forEach((a) => {
a.style.cursor = "grabbing";
});
};
navPills.querySelectorAll("a").forEach((a) => {
a.style.cursor = "grabbing";
});
const removeDragScroll = function () {
document.removeEventListener("mousemove", mouseDragScroll);
navPills.querySelectorAll("a").forEach((a) => {
a.style.cursor = "pointer";
});
};
document.addEventListener("mousemove", mouseDragScroll, { once: true });
document.addEventListener("mousemove", mouseDragScroll);
document.addEventListener("mouseup", removeDragScroll, { once: true });
}