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

Package detail

ember-gesture-modifiers

nickschot15kMIT6.1.0

Addon that provides gestures as modifiers.

ember-addon, gestures

readme

ember-gesture-modifiers

Addon that provides gestures as modifiers.

Compatibility

  • Ember.js v3.28 or above
  • Embroider or ember-auto-import v2

Installation

ember install ember-gesture-modifiers

Usage

Currently only a Pan modifier is provided. More gestures will be added in the future.

Pan modifier

<div
  {{did-pan
    onPanStart=this.didPanStart
    onPan=this.didPan
    onPanEnd=this.didPanEnd
  }}
>

arguments

  • onPanStart - hook fired when a pan is started
  • onPan - hook fired when the pan is updated
  • onPanEnd - hook fired when a pan has ended
  • threshold (default: 10) - minimum touch movement needed in px to start a pan
  • axis (default: 'horizontal') - axis for the pan event to be recognized ('horizontal', 'vertical' or 'both')
  • capture (default: false) - whether or not to use capture events instead of bubbling
  • preventScroll (default: true) - whether or not to prevent scroll during panning
  • pointerTypes (default: ['touch']) - the pointer types to support (one or more of 'touch', 'mouse', 'pen')

The hooks are passed a TouchData object which looks like:

{
  originalEvent: <TouchEvent>,
  timeStamp: 2896.435000002384,
  initial: {
    x: 427.87109375,
    y: 276.98046875,
    timeStamp: 2251.9500000053085
  },
  current: {
    deltaX: 0,
    deltaY: 0,
    x: 192.95703125,
    y: 279.12890625,
    distance: 234.92388670364133,
    distanceX: -234.9140625,
    distanceY: 2.1484375,
    angle: 180.52399148917002,
    overallVelocityX: -0.36449888283057935,
    overallVelocityY: 0.0033335725424327154,
    overallVelocity: -0.36449888283057935,
    velocityX: -0.03269026669500546,
    velocityY: 0,
    velocity: -0.03269026669500546
  },
  cache: {
    velocity: {
      distanceX: -234.9140625,
      distanceY: 2.1484375,
      timeStamp: 2613.435000006575
    }
  }
}

Testing

A pan test helper is exposed by the addon.

import { pan } from 'ember-gesture-modifiers/test-support';

...

// arg1: CSS selector on which the pan happens
// arg2: a direction in which the pan should happen. Either 'left', 'right', 'down', 'up' or 'up-right'.
await pan('.my-css-selector', 'right');

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

changelog

Changelog

Release (2025-03-14)

  • ember-gesture-modifiers 6.1.0 (minor)

:rocket: Enhancement

  • ember-gesture-modifiers
    • #854 Update v2 addon blueprint (inc. decorator-transforms) (@nickschot)

:house: Internal

Committers: 1

v6.0.1 (2023-12-21)

:bug: Bug Fix

Committers: 1

v6.0.0 (2023-12-08)

:boom: Breaking Change

:rocket: Enhancement

:house: Internal

Committers: 1

v5.0.1 (2023-04-07)

:rocket: Enhancement

Committers: 1

v5.0.0 (2023-02-03)

:boom: Breaking Change

Committers: 1

v4.0.1 (2022-09-14)

:bug: Bug Fix

  • #325 Require ember-modifier v3.2.0+ to make sure the new modifier syntax is available (@nickschot)

Committers: 1

v4.0.0 (2022-09-14)

:boom: Breaking Change

:bug: Bug Fix

  • #137 use document based event handlers for pointer move/up/cancel for all pointer types (@nickschot)
  • #71 fix parse-touch-data re-export (@nickschot)

:house: Internal

Committers: 2

v1.1.1 (2021-07-07)

:bug: Bug Fix

  • #69 fix pan test-helper calculating coordinates for intermediate events incorrectly in certain cases (@nickschot)

Committers: 1

v1.1.0 (2021-06-17)

:rocket: Enhancement

  • #60 Add vertical & bi-directional test coverage & pan test-helper extension (@nickschot)

:bug: Bug Fix

  • #53 fix capture argument not working & add test coverage (@nickschot)

:memo: Documentation

  • #42 fix minimum supported Ember.js version in README (@nickschot)

:house: Internal

Committers: 1

v1.1.0-beta.1 (2021-02-03)

:rocket: Enhancement

:memo: Documentation

Committers: 1

v1.0.0 (2020-11-19)

:boom: Breaking Change

  • #16 implement PointerEvents (replacing TouchEvents) (@nickschot)

:rocket: Enhancement

  • #16 implement PointerEvents (replacing TouchEvents) (@nickschot)

:memo: Documentation

  • #15 Add code comments to explain touch-action setting (@lolmaus)

Committers: 2

v0.2.0 (2020-08-05)

:boom: Breaking Change

  • #11 set touchmove event listener's passive option to false when the preventScroll argument is passed, remove passive argument (@nickschot)

:house: Internal

Committers: 1

v0.1.1 (2020-03-01)

:house: Internal

Committers: 1