Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

aurelia-hammer

benib14MIT0.1.0

A plugin for Aurelia providing Custom Attributes for Hammer.JS

aurelia, plugin, hammer, touch, gestures

readme

aurelia-hammer

This is a Aurelia plugin providing the hammer-swipe and hammer-tap and hammer-press and hammer-hold Custom Attributes.

It uses HammerJS to detect the gesture.

swipe, tap, press, and hold are the only gestures supported at the moment. If you need another, feel free to open an issue or send a PR.

  • Swipe - Captures left/right swipe gestures
  • Tap - Captures when the pointer is down for up to 250ms without movement
  • Press - Captures when the pointer is down for 251ms without movement
  • Hold - Captures when the pointer is down for 1000ms without movement

Installation

jspm install github:benib/aurelia-hammer

Then load like this in your apps configure function:

aurelia.use
  //...
  .plugin('benib/aurelia-hammer')
  //...

Swipe Usage

In your View

<div hammer-swipe.call="handleSwipe($event)">
</div>

In your View Model

handleSwipe($event) {
  if ($event.direction === 'left') {

  } else if ($event.direction === 'right') {

  }
  // here you have $event.hammerEvent holding the original event from HammerJS.
}

Tap Usage

In your View

<div hammer-tap.call="handleTap($event)">
</div>

In your View Model

handleTap($event) {

  // here you have $event.hammerEvent holding the original event from HammerJS.
}

Press Usage

In your View

<div hammer-press.call="handlePress($event)">
</div>

In your View Model

handlePress($event) {

  // here you have $event.hammerEvent holding the original event from HammerJS.
}

Hold Usage

In your View

<div hammer-hold.call="handleHold($event)">
</div>

In your View Model

handleHold($event) {

  // here you have $event.hammerEvent holding the original event from HammerJS.
}

changelog

0.1.0 (2016-05-17)

  • add hammer-tap, hammer-press and hammer-hold custom attributes

0.0.2 (2015-09-17)

  • Fix wrong path

0.0.1 (2015-09-17)

Inital release of aurelia-hammer

  • only swipe is supported by now via hammer-swipe Custom Attribute