ionic-team / ng-cordova

OBSOLETE: Please move to Ionic Native https://github.com/ionic-team/ionic-native
https://github.com/ionic-team/ionic-native
MIT License
3.48k stars 1.05k forks source link

Bug: Event is not included in the $cordovaKeyboard:show broadcast. #998

Open 5amfung opened 9 years ago

5amfung commented 9 years ago

Should I add event to keyboardShowEvent() and $broadcast()?

https://github.com/driftyco/ng-cordova/blob/master/src/plugins/keyboard.js#L8

var keyboardShowEvent = function (event) {
  $rootScope.$evalAsync(function () {
    $rootScope.$broadcast('$cordovaKeyboard:show', event);
  });
};

When the keyboard opens, it does a $broadcast, but the original event object is not included. So the listener can't get the information (like keyboard height) that is embedded in the event object.

I want to make sure this is correct before I submit a pull request. Please let me know.

5amfung commented 9 years ago

Anyone could comment on this?

nikkow commented 8 years ago

Hi,

I am facing the same issue and was about to submit a bug :) I managed to fix the behavior by slightly updating your code. Since the only useful information is -at least in my case- the keyboardHeight, I do not forward the entire event (which would create an object with only one key: keyboardHeight), but only the keyboard height information:

var keyboardShowEvent = function (event) {
  $rootScope.$evalAsync(function () {
    $rootScope.$broadcast('$cordovaKeyboard:show', event.keyboardHeight);
  });
};