feat: improve task search reveal interaction
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
export const SEARCH_PULL_THRESHOLD = 56
|
||||
export const SEARCH_PULL_LIMIT = 72
|
||||
export const SEARCH_HIDE_SWIPE_THRESHOLD = 36
|
||||
|
||||
export function clampSearchPullDistance(distance: number) {
|
||||
return Math.min(SEARCH_PULL_LIMIT, Math.max(0, distance))
|
||||
}
|
||||
|
||||
export function shouldRevealSearchAfterPull(distance: number) {
|
||||
return distance >= SEARCH_PULL_THRESHOLD
|
||||
}
|
||||
|
||||
export function isAtSearchPullOrigin(...scrollPositions: number[]) {
|
||||
return scrollPositions.every((position) => position <= 0)
|
||||
}
|
||||
|
||||
export function shouldHideSearchAfterSwipe(deltaY: number, query: string) {
|
||||
return !query.trim() && deltaY <= -SEARCH_HIDE_SWIPE_THRESHOLD
|
||||
}
|
||||
|
||||
export function isSearchShortcut(event: Pick<KeyboardEvent, 'key' | 'metaKey' | 'ctrlKey'>) {
|
||||
return (event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'k'
|
||||
}
|
||||
Reference in New Issue
Block a user