Skip to content

Commit

Permalink
Debounce slider inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Koopzington committed Sep 10, 2024
1 parent 950ecdd commit cb54e6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2024-09-10
- Debounce inputs for sliders to improve user experience while entering numbers

## 2024-08-27
- Fixed a bug where sliders would pass decimal numbers to the API (e.g. UI shows 6 main characters but sends 5.6785)
- Updated dependencies
Expand Down
8 changes: 8 additions & 0 deletions src/Filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,14 +870,22 @@ class Filters extends EventTarget {
}
})

let debouncer: number

minField.addEventListener('keyup', () => {
clearTimeout(debouncer)
debouncer = setTimeout(() => {
container.noUiSlider.set([minField.value, null])
this.filterChangeCallback()
}, 500);
})

maxField.addEventListener('keyup', () => {
clearTimeout(debouncer)
debouncer = setTimeout(() => {
container.noUiSlider.set([null, maxField.value])
this.filterChangeCallback()
}, 500);
})
}

Expand Down

0 comments on commit cb54e6e

Please sign in to comment.