Created
April 2, 2013 14:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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