Sebastiankay's picture
28. Sept. 2024, 12:24
3a1812f
raw
history blame
864 Bytes
function gradioCustomJS() {
console.log("gradioCustomJS Started")
//component-15
const tabNav = document.querySelector("div.tab-nav")
tabNav.addEventListener("mouseover", () => {
tabNav.addEventListener("wheel", (event) => {
event.preventDefault()
let scrollLeft = 0
if (Math.sign(event.deltaY) < 0) {
scrollLeft = tabNav.scrollLeft - 15
}
if (Math.sign(event.deltaY) > 0) {
scrollLeft = tabNav.scrollLeft + 15
}
tabNav.scrollLeft = Math.max(0, Math.min(scrollLeft, tabNav.scrollWidth - tabNav.clientWidth))
})
})
tabNav.addEventListener("mouseout", () => {
tabNav.removeEventListener("wheel", (event) => {
event.preventDefault()
// const scrollLeft = tabNav.scrollLeft + 10
// tabNav.scrollLeft = Math.max(0, Math.min(scrollLeft, tabNav.scrollWidth - tabNav.clientWidth))
})
})
return "Custom Gradio JS"
}