Hello!
I've been trying all day to make a swipe work with a backbone and I have not had any luck. I have a code that works but it's pretty ugly and from what I've seen it can be structured better. The problem is that when I integrate it into Backbone, it does not work at all. The code that is commented is the one that works.
I tried to follow this article , and this , and this ...
Can someone tell me what I'm doing wrong?
var app = app || {};
$(function () {
app.tabsContent = Backbone.View.extend({
tagname: '#tabs-container',
events: {
'swipe #tabs-header': 'swipeIt'
},
initialize: function () {
this.$list = $('#group-list');
this.$el.hammer();
// let swipeTabs = document.getElementById('tabs-header');
// let mc = new Hammer(swipeTabs);
// mc.get('swipe').set({ direction: Hammer.DIRECTION_ALL });
// mc.on("swipe", this.swipeIt);
app.groupCollection.fetch();
this.listenTo(app.groupCollection, 'add', this.appendOne);
},
render: function () {
},
appendOne: function (group) {
let view = new app.GroupView({model: group});
this.$list.append(view.render().el);
},
swipeIt: function (e) {
if (e.direction == 8) {
console.log('Swipe up')
} else if (e.direction == 16) {
console.log('Swipe down')
}
}
})
})