1
0
Fork 0
mirror of synced 2024-07-29 10:05:55 +12:00

Debounce hiding side panel to avoid toggling visibility when cycling through records

This commit is contained in:
Andrew Kingston 2022-12-06 09:55:42 +00:00
parent 44e8676aab
commit aacfe297bc

View file

@ -11,18 +11,25 @@ export const createSidePanelStore = () => {
open: $store.contentId != null,
}
})
let timeout
const open = id => {
clearTimeout(timeout)
store.update(state => {
state.contentId = id
return state
})
}
// Delay closing by 50ms to avoid toggling visibility when cycling though
// records
const close = () => {
store.update(state => {
state.contentId = null
return state
})
timeout = setTimeout(() => {
store.update(state => {
state.contentId = null
return state
})
}, 50)
}
return {