Skip to content

ion-directives could broadcast gestures to controller #647

@gregaton

Description

@gregaton

Instead of only supporting touch/click events with a fixed behavior the directives could also support other gestures and broadcast them to the corresponding controller.

I said could because I'm not sure what potential drawbacks all those event listeners and broadcast messages could have.

To give a practical example, I am currently using the following directive to allow hold gestures for my tabs.

module.directive('ionTabControllerItem', ['$rootScope', '$ionicGesture', function($rootScope, $ionicGesture) {
  return {
    priority: -10,
    restrict: 'E',
    require: '^ionTabs',
    compile: function(element, attr, transclude) {
      return function link(scope, element, attrs, tabsCtrl) {
        $ionicGesture.on('hold', function(e) {
          $rootScope.$broadcast('tab.hold', scope.$index);
        }, element);
      };
    }
  };
}]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions