mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(android): when keyboard comes up, ensure input is in view
This requires us to set fullscreen="false" in our cordova apps. Uses the resize event to determine when the keyboard has been shown, then broadcasts an event from the activeElement: 'scrollChildIntoView', which is caught by the nearest parent scrollView. The scrollView will then see if that element is within the new device's height (since the keyboard resizes the screen), and if not scroll it into view. Additionally, when the keyboard resizes the screen we add a `.hide-footer` class to the body, which will hide tabbars and footer bars while the keyboard is opened. For now, this is android only. Closes #314.
This commit is contained in:
@@ -6,7 +6,10 @@ describe('$ionicScroll Controller', function() {
|
||||
function setup(options) {
|
||||
options = options || {};
|
||||
|
||||
options.el = options.el || document.createElement('div');
|
||||
options.el = options.el ||
|
||||
//scrollView requires an outer container element and a child
|
||||
//content element
|
||||
angular.element('<div><div></div></div>')[0];
|
||||
|
||||
inject(function($controller, $rootScope, $timeout) {
|
||||
scope = $rootScope.$new();
|
||||
@@ -41,6 +44,25 @@ describe('$ionicScroll Controller', function() {
|
||||
expect(ctrl.scrollView.run).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should resize the scrollview on window resize', function() {
|
||||
setup();
|
||||
timeout.flush();
|
||||
spyOn(ctrl.scrollView, 'resize');
|
||||
ionic.trigger('resize', { target: window });
|
||||
expect(ctrl.scrollView.resize).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should unbind window event listener on scope destroy', function() {
|
||||
spyOn(window, 'removeEventListener');
|
||||
spyOn(window, 'addEventListener');
|
||||
setup();
|
||||
expect(window.addEventListener).toHaveBeenCalled();
|
||||
expect(window.addEventListener.mostRecentCall.args[0]).toBe('resize');
|
||||
scope.$destroy();
|
||||
expect(window.removeEventListener).toHaveBeenCalled();
|
||||
expect(window.removeEventListener.mostRecentCall.args[0]).toBe('resize');
|
||||
});
|
||||
|
||||
it('should register with $ionicScrollDelegate', inject(function($ionicScrollDelegate) {
|
||||
spyOn($ionicScrollDelegate, 'register');
|
||||
setup();
|
||||
|
||||
Reference in New Issue
Block a user