File tree 1 file changed +25
-1
lines changed
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 8
8
9
9
let resetConfirm = 3 ;
10
10
11
+
11
12
$ : if (resetConfirm === 0 ) {
12
13
calorieDateMap .reset ();
13
14
// Set resetConfirm back to 3 after 1500 milliseconds
54
55
newDate .setDate (newDate .getDate () + 1 );
55
56
updateDateQuery (newDate .toDateString ());
56
57
}
58
+
59
+ // For swiping to change date
60
+ let startX: number ;
61
+ let endX: number ;
62
+
63
+ function handleSwipe() {
64
+ if (startX - endX > 50 ) {
65
+ handleDateForward ();
66
+ } else if (endX - startX > 50 ) {
67
+ handleDateBack ();
68
+ }
69
+ }
70
+
71
+ function handleTouchStart(event : TouchEvent ) {
72
+ startX = event .touches [0 ].clientX ;
73
+ }
74
+ function handleTouchEnd(event : TouchEvent ) {
75
+ endX = event .changedTouches [0 ].clientX ;
76
+ handleSwipe ();
77
+ }
57
78
</script >
58
79
59
80
<svelte:head >
68
89
<button on:click ={handleDateBack }>
69
90
{' <' }
70
91
</button >
71
- <h2 >
92
+ <h2
93
+ on:touchstart ={handleTouchStart }
94
+ on:touchend ={handleTouchEnd }
95
+ >
72
96
{pathname }
73
97
</h2 >
74
98
<button on:click ={handleDateForward }>
You can’t perform that action at this time.
0 commit comments