-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gestures): add basic gesture demos
- Loading branch information
Showing
8 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} | ||
}; | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="demo-gestures"> | ||
<div (longpress)="pressCount = pressCount + 1" (drag)="dragCount = dragCount + 1" | ||
(swipe)="swipeCount = swipeCount + 1"> | ||
Drag or press me. | ||
</div> | ||
drag: {{dragCount}} | ||
swipe: {{swipeCount}} | ||
longpress: {{pressCount}} | ||
</div> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.demo-gestures div { | ||
height: 100px; | ||
width: 200px; | ||
background: gray; | ||
padding: 15px; | ||
color: #FFF; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {Component} from 'angular2/core'; | ||
|
||
@Component({ | ||
selector: 'gestures-demo', | ||
templateUrl: 'demo-app/gestures/gestures-demo.html', | ||
styleUrls: ['demo-app/gestures/gestures-demo.css'], | ||
directives: [] | ||
}) | ||
export class GesturesDemo { | ||
dragCount: number = 0; | ||
pressCount: number = 0; | ||
swipeCount: number = 0; | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import {bootstrap} from 'angular2/platform/browser'; | ||
import {HAMMER_GESTURE_CONFIG} from 'angular2/src/platform/browser_common'; | ||
import {DemoApp} from './demo-app/demo-app'; | ||
import {ROUTER_PROVIDERS} from 'angular2/router'; | ||
import {OVERLAY_CONTAINER_TOKEN} from './core/overlay/overlay'; | ||
import {MdLiveAnnouncer} from './core/live-announcer/live-announcer'; | ||
import {provide} from 'angular2/core'; | ||
import {createOverlayContainer} from './core/overlay/overlay-container'; | ||
import {MdGestureConfig} from './core/gestures/MdGestureConfig'; | ||
|
||
bootstrap(DemoApp, [ | ||
ROUTER_PROVIDERS, | ||
MdLiveAnnouncer, | ||
provide(OVERLAY_CONTAINER_TOKEN, {useValue: createOverlayContainer()}), | ||
provide(HAMMER_GESTURE_CONFIG, {useClass: MdGestureConfig}) | ||
]); |