Skip to content

Commit

Permalink
fix: avoid false positives for limit hit
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Oct 11, 2023
1 parent 16739dc commit 021ce42
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/components/Clustering.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,26 @@ function Clustering({ category, children }) {

React.useEffect(() => {
setLimitHit(
userCluster ||
(children.length > rules.forcedLimit &&
!IGNORE_CLUSTERING.has(category))
children.length > rules.forcedLimit && !IGNORE_CLUSTERING.has(category)
? !!rules.forcedLimit
: false,
)
}, [category, userCluster, rules.forcedLimit, children.length])

React.useEffect(() => {
if (limitHit) {
if (limitHit || userCluster) {
setSuperCluster(
new Supercluster({
radius: 60,
extent: 256,
maxZoom: rules.zoomLevel,
minPoints: category === 'pokemon' ? 4 : 3,
minPoints: category === 'pokemon' ? 7 : 5,
}),
)
} else {
setSuperCluster(null)
}
}, [rules.zoomLevel, limitHit, category])
}, [rules.zoomLevel, limitHit, userCluster, category])

React.useEffect(() => {
if (superCluster) {
Expand Down

0 comments on commit 021ce42

Please sign in to comment.