You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.4 KiB

  1. /*!
  2. * Angular Material Design
  3. * https://github.com/angular/material
  4. * @license MIT
  5. * v1.1.1
  6. */
  7. (function( window, angular, undefined ){
  8. "use strict";
  9. /**
  10. * @ngdoc module
  11. * @name material.components.swipe
  12. * @description Swipe module!
  13. */
  14. /**
  15. * @ngdoc directive
  16. * @module material.components.swipe
  17. * @name mdSwipeLeft
  18. *
  19. * @restrict A
  20. *
  21. * @description
  22. * The md-swipe-left directive allows you to specify custom behavior when an element is swiped
  23. * left.
  24. *
  25. * @usage
  26. * <hljs lang="html">
  27. * <div md-swipe-left="onSwipeLeft()">Swipe me left!</div>
  28. * </hljs>
  29. */
  30. /**
  31. * @ngdoc directive
  32. * @module material.components.swipe
  33. * @name mdSwipeRight
  34. *
  35. * @restrict A
  36. *
  37. * @description
  38. * The md-swipe-right directive allows you to specify custom behavior when an element is swiped
  39. * right.
  40. *
  41. * @usage
  42. * <hljs lang="html">
  43. * <div md-swipe-right="onSwipeRight()">Swipe me right!</div>
  44. * </hljs>
  45. */
  46. /**
  47. * @ngdoc directive
  48. * @module material.components.swipe
  49. * @name mdSwipeUp
  50. *
  51. * @restrict A
  52. *
  53. * @description
  54. * The md-swipe-up directive allows you to specify custom behavior when an element is swiped
  55. * up.
  56. *
  57. * @usage
  58. * <hljs lang="html">
  59. * <div md-swipe-up="onSwipeUp()">Swipe me up!</div>
  60. * </hljs>
  61. */
  62. /**
  63. * @ngdoc directive
  64. * @module material.components.swipe
  65. * @name mdSwipeDown
  66. *
  67. * @restrict A
  68. *
  69. * @description
  70. * The md-swipe-down directive allows you to specify custom behavior when an element is swiped
  71. * down.
  72. *
  73. * @usage
  74. * <hljs lang="html">
  75. * <div md-swipe-down="onSwipDown()">Swipe me down!</div>
  76. * </hljs>
  77. */
  78. angular.module('material.components.swipe', ['material.core'])
  79. .directive('mdSwipeLeft', getDirective('SwipeLeft'))
  80. .directive('mdSwipeRight', getDirective('SwipeRight'))
  81. .directive('mdSwipeUp', getDirective('SwipeUp'))
  82. .directive('mdSwipeDown', getDirective('SwipeDown'));
  83. function getDirective(name) {
  84. DirectiveFactory.$inject = ["$parse"];
  85. var directiveName = 'md' + name;
  86. var eventName = '$md.' + name.toLowerCase();
  87. return DirectiveFactory;
  88. /* ngInject */
  89. function DirectiveFactory($parse) {
  90. return { restrict: 'A', link: postLink };
  91. function postLink(scope, element, attr) {
  92. var fn = $parse(attr[directiveName]);
  93. element.on(eventName, function(ev) {
  94. scope.$applyAsync(function() { fn(scope, { $event: ev }); });
  95. });
  96. }
  97. }
  98. }
  99. })(window, window.angular);