Skip to content

Instantly share code, notes, and snippets.

@jacobheric
Created April 2, 2013 14:04
Show Gist options
  • Save jacobheric/5292450 to your computer and use it in GitHub Desktop.
Save jacobheric/5292450 to your computer and use it in GitHub Desktop.
An example tying hammer.js gesture support into a meteor managed template element via the template.rendered event
Template.thing.rendered = function(template){
var element = this.find('.thingContainer');
var id = this.data._id;
if (element) {
Hammer(element).on("dragleft", dragLeft);
Hammer(element).on("dragright", dragRight);
}
}
var removeItem = function(id){
Meteor.call('removeListItem', id);
}
var dragLeft = function(ev, id){
var touches = ev.gesture.touches;
ev.gesture.preventDefault();
//
//Hokey: current doc id is bound to dom el id
//cause we don't have it in this contex
var docId = ev.target.id;
for (var t = 0, len = touches.length; t < len; t++) {
var target = $(touches[t].target);
target.css({
left: touches[t].pageX - 250
});
}
removeItem(docId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment