Skip to content

Commit

Permalink
swipe planets with selector closed
Browse files Browse the repository at this point in the history
  • Loading branch information
wellcaffeinated committed Mar 5, 2024
1 parent 1b024a8 commit e57e5ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/components/PlanetSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
if (Math.abs(v) > MIN_FLICK_VEL) {
ds = Math.max(ds, dangle * scale)
}
if (!selectorOpen) {
ds = Math.min(ds, dangle * scale)
}
// get the closest planet to end position
const x = pos + ds * Math.sign(v)
let i = Math.round(x / dangle / scale)
Expand All @@ -81,9 +84,16 @@
})
clearTimeout(timer)
timer = setTimeout(() => {
if (selectorOpen) {
timer = setTimeout(() => {
changePlanet(planetIndex)
}, time + 500)
} else {
changePlanet(planetIndex)
}, time + 500)
timer = setTimeout(() => {
selectPlanet()
}, time)
}
}
const moveToPlanet = (name, done) => {
Expand Down Expand Up @@ -115,7 +125,9 @@
clearTimeout(timer)
},
move(e){
pos += e.dx
if (selectorOpen) {
pos += e.dx
}
},
end(e){
flick(e.velocity.x / 1000)
Expand Down
2 changes: 1 addition & 1 deletion src/components/PlanetSelectorScene.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
if (showAll) {
return { scale: 1 }
} else {
return { scale: 1e-10 }
return { scale: 1e-2 }
}
}),
smoothen({ duration: '0.5s', easing: 'quadOut' })
Expand Down

0 comments on commit e57e5ca

Please sign in to comment.