Skip to content

Commit

Permalink
feat: Prevent swiping when zoomed
Browse files Browse the repository at this point in the history
  • Loading branch information
artonge committed Aug 31, 2024
1 parent 2140d61 commit 2cdc67b
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/components/WeatherForecasts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,19 @@ function handleHoldStart(event: HoldStartEvent) {
return
}
// Allow swiping to next or previous chart when on edges.
if (zoom.value.min === forecast.value?.hourly[0].time.getTime()) {
return
}
if (zoom.value.max === forecast.value?.hourly[forecast.value.hourly.length - 1].time.getTime()) {
return
}
console.debug("Flicking: abort flick")
event.stop()
return
// // Allow swiping to next or previous chart when on edges.
// if (zoom.value.min === forecast.value?.hourly[0].time.getTime()) {
// return
// }
// if (zoom.value.max === forecast.value?.hourly[forecast.value.hourly.length - 1].time.getTime()) {
// return
// }
// console.debug("Flicking: abort flick")
// event.stop()
}
function handleMoveStart(event: MoveStartEvent) {
Expand All @@ -84,15 +87,18 @@ function handleMoveStart(event: MoveStartEvent) {
return
}
if (zoom.value.min === forecast.value?.hourly[0].time.getTime() && event.direction === 'NEXT') {
console.debug("Flicking: abort flick")
event.stop()
}
event.stop()
return
if (zoom.value.max === forecast.value?.hourly[forecast.value.hourly.length - 1].time.getTime() && event.direction === 'PREV') {
console.debug("Flicking: abort flick")
event.stop()
}
// if (zoom.value.min === forecast.value?.hourly[0].time.getTime() && event.direction === 'NEXT') {
// console.debug("Flicking: abort flick")
// event.stop()
// }
// if (zoom.value.max === forecast.value?.hourly[forecast.value.hourly.length - 1].time.getTime() && event.direction === 'PREV') {
// console.debug("Flicking: abort flick")
// event.stop()
// }
}
function handlePanelChanged({index}: WillChangeEvent) {
Expand Down

0 comments on commit 2cdc67b

Please sign in to comment.