2 * Angular Material Design
3 * https://github.com/angular/material
7 goog.provide('ngmaterial.components.swipe');
8 goog.require('ngmaterial.core');
11 * @name material.components.swipe
12 * @description Swipe module!
16 * @module material.components.swipe
22 * The md-swipe-left directive allows you to specify custom behavior when an element is swiped
27 * <div md-swipe-left="onSwipeLeft()">Swipe me left!</div>
32 * @module material.components.swipe
38 * The md-swipe-right directive allows you to specify custom behavior when an element is swiped
43 * <div md-swipe-right="onSwipeRight()">Swipe me right!</div>
48 * @module material.components.swipe
54 * The md-swipe-up directive allows you to specify custom behavior when an element is swiped
59 * <div md-swipe-up="onSwipeUp()">Swipe me up!</div>
64 * @module material.components.swipe
70 * The md-swipe-down directive allows you to specify custom behavior when an element is swiped
75 * <div md-swipe-down="onSwipDown()">Swipe me down!</div>
79 angular.module('material.components.swipe', ['material.core'])
80 .directive('mdSwipeLeft', getDirective('SwipeLeft'))
81 .directive('mdSwipeRight', getDirective('SwipeRight'))
82 .directive('mdSwipeUp', getDirective('SwipeUp'))
83 .directive('mdSwipeDown', getDirective('SwipeDown'));
85 function getDirective(name) {
86 DirectiveFactory['$inject'] = ["$parse"];
87 var directiveName = 'md' + name;
88 var eventName = '$md.' + name.toLowerCase();
90 return DirectiveFactory;
93 function DirectiveFactory($parse) {
94 return { restrict: 'A', link: postLink };
95 function postLink(scope, element, attr) {
96 element.css('touch-action', 'none');
98 var fn = $parse(attr[directiveName]);
99 element.on(eventName, function(ev) {
100 scope.$applyAsync(function() { fn(scope, { $event: ev }); });
108 ngmaterial.components.swipe = angular.module("material.components.swipe");