Add swipe gesture recognition to popup show button

Hi so I have been using Ionic for about a week now, and after thoroughly inspecting the library documents, it doesn’t appear as though the button objects in the $ionicPopup class are able to register swipe gestures.

I would like to add this functionality and was wondering where I should start. I am guessing that I will have to create my own custom button object with an added field to register on swipe gestures in the app.js file. But I am unsure I will then nest my new custom button object inside of the preexisting $IonicPopup class.

A simple swipe that closes the $IonicPopup class would suffice for me.

Any advice as to how and where I should start/complete this task would be greatly appreciated.

Could you use a directive coded against the “popup” class to call a $scope function on swipe? Something like…

.directive('menuToggle', ['$ionicViewService', function($ionicViewService) {
  return {
    restrict: 'C',
    require: '^popup',
    link: function($scope, $element, $attr, sideMenuCtrl) {
      $element.bind('swipe', function(){

NOTE: Not production ready code.

1 Like

'll just need a bit of time to learn enough angualr to implement a version of your solution, but I will give it a try and report back!

But use $element.on instead $element.bind.

“bind” will be maybe removed in the future.
“on” is the current suggested and right solution for jquery.


1 Like