I have a component that shows information for days that are cycled through with functions dayUp()
and dayDown()
. They both look like the following:
dayUp() {
if (this.dayCount == 7) {
return;
}
this.dayCount++;
if (this.dayCount == 0) {
this.today = 'Today'
} else if (this.dayCount == 1) {
this.today = 'Tomorrow'
} else if (this.dayCount == -1) {
this.today = 'Yesterday'
} else {
this.today = '';
}
this.getSelectedDay(this.dayCount);
}
I am calling these functions with buttons for each one. They work as expected and updates the view with the new information accordingly. I am tying to add swipe functionality to do the same thing with gestures using HammerJS. I have it set up and the swipes are working with the correct directions. I have a console log to test. I have the dayDown()
set to swipe left and dayUp()
set to swipe right. I can tell from the debugger that they are both indeed being called correctly and the function is running and changing the value of the dayCount
variable. The issue is that the view is not updating or responding at all like it does when the functions are called from the button. To be clear, I am calling the same exact function with the button as well as the swipe. The buttons work as expected but they are not working when called through the swipe. I'm not sure what is causing this. The HammerJS code is below:
const switcher = document.getElementById('switcher');
var mc = new hammer(switcher);
mc.on('swipeleft', () => {
console.log('left');
this.dayDown();
});
mc.on('swiperight', () => {
console.log('right');
this.dayUp();
});