From d4a3cde52ba736da64285bdfaf039129d0dd8312 Mon Sep 17 00:00:00 2001 From: Kara Erickson Date: Wed, 13 Apr 2016 16:19:14 -0700 Subject: [PATCH] feat(gestures): add basic gesture demos --- src/core/gestures/MdGestureConfig.ts | 26 ++++++++++++++++++++++++ src/demo-app/demo-app.html | 1 + src/demo-app/demo-app.ts | 5 +++-- src/demo-app/gestures/gestures-demo.html | 9 ++++++++ src/demo-app/gestures/gestures-demo.scss | 7 +++++++ src/demo-app/gestures/gestures-demo.ts | 13 ++++++++++++ src/index.html | 3 +++ src/main.ts | 3 +++ 8 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/core/gestures/MdGestureConfig.ts create mode 100644 src/demo-app/gestures/gestures-demo.html create mode 100644 src/demo-app/gestures/gestures-demo.scss create mode 100644 src/demo-app/gestures/gestures-demo.ts diff --git a/src/core/gestures/MdGestureConfig.ts b/src/core/gestures/MdGestureConfig.ts new file mode 100644 index 00000000000..21a7f295fb4 --- /dev/null +++ b/src/core/gestures/MdGestureConfig.ts @@ -0,0 +1,26 @@ +import {Injectable} from 'angular2/core'; +import {HammerGestureConfig} from 'angular2/src/platform/browser_common'; + +/* Adjusts configuration of our gesture library, Hammer. */ +@Injectable() +export class MdGestureConfig extends HammerGestureConfig { + /* List of new event names to add to the gesture support list */ + events: string[] = ['drag', 'longpress']; + + /* + * Overrides default recognizer event names and thresholds. + * + * Our gesture names come from the Material Design gestures spec: + * https://www.google.com/design/spec/patterns/gestures.html#gestures-touch-mechanics + * + * More information on default recognizers can be found in Hammer docs: + * http://hammerjs.github.io/recognizer-pan/ + * http://hammerjs.github.io/recognizer-press/ + * + * TODO: Confirm threshold numbers with Material Design UX Team + * */ + overrides: {[key: string]: Object} = { + 'pan': {event: 'drag', threshold: 6}, + 'press': {event: 'longpress', time: 500} + }; +} diff --git a/src/demo-app/demo-app.html b/src/demo-app/demo-app.html index c7e961ce53b..76a1d72b49e 100644 --- a/src/demo-app/demo-app.html +++ b/src/demo-app/demo-app.html @@ -14,6 +14,7 @@
  • List demo
  • Live Announcer demo
  • Sidenav demo
  • +
  • Gestures demo