Debounce hiding side panel to avoid toggling visibility when cycling through records
This commit is contained in:
parent
44e8676aab
commit
aacfe297bc
1 changed files with 11 additions and 4 deletions
|
@ -11,18 +11,25 @@ export const createSidePanelStore = () => {
|
||||||
open: $store.contentId != null,
|
open: $store.contentId != null,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
let timeout
|
||||||
|
|
||||||
const open = id => {
|
const open = id => {
|
||||||
|
clearTimeout(timeout)
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
state.contentId = id
|
state.contentId = id
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delay closing by 50ms to avoid toggling visibility when cycling though
|
||||||
|
// records
|
||||||
const close = () => {
|
const close = () => {
|
||||||
store.update(state => {
|
timeout = setTimeout(() => {
|
||||||
state.contentId = null
|
store.update(state => {
|
||||||
return state
|
state.contentId = null
|
||||||
})
|
return state
|
||||||
|
})
|
||||||
|
}, 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue