Skip to content

Instance methods

Jorik Tangelder edited this page Sep 1, 2014 · 4 revisions

This WIKI is for the 1.1 version. For the 2.0 documentation, go to the website.

The Hammer instance you've just created has these methods you can use to do your magic. The instance variable is called hammertime.

###hammertime.on(gesture, handler) Add an event listener for the gesture. This also can contain multiple gestures, separated by a space. (just like jQuery).

###hammertime.off(gesture, handler) Remove the handler for the given gesture.

###hammertime.enable(toggle) Enable or disable detection on this element, so nothing happens while touching the element. When you have some serious performance problems on your page this could be a method to use. But it probably is better to optimize/unbind your event handlers!

###hammertime.trigger(gesture, eventData) You shouldn't use this, this is an internally method use by the gestures. Only use it when you know what you're doing! You can read the sourcecode about how to use this.