From 467771ad9ccf8278fb6d049b3dd99294b37d6307 Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Mon, 12 Dec 2016 18:01:41 +0000 Subject: [PATCH] Revert "MOBILE-1849 ios: Scroll if focused element is outside of screen" This reverts commit 419375f97b70a0a3cef898e5dc300bd75799c466. --- www/core/lib/util.js | 36 +----------------------------------- www/core/main.js | 16 +--------------- 2 files changed, 2 insertions(+), 50 deletions(-) diff --git a/www/core/lib/util.js b/www/core/lib/util.js index 16a6b983449..c8b3a446618 100644 --- a/www/core/lib/util.js +++ b/www/core/lib/util.js @@ -68,8 +68,7 @@ angular.module('mm.core') this.$get = function($ionicLoading, $ionicPopup, $injector, $translate, $http, $log, $q, $mmLang, $mmFS, $timeout, $mmApp, $mmText, mmCoreWifiDownloadThreshold, mmCoreDownloadThreshold, $ionicScrollDelegate, $mmWS, $cordovaInAppBrowser, - $mmConfig, mmCoreSettingsRichTextEditor, $rootScope, $ionicPlatform, $ionicHistory, mmCoreSplitViewBlock, $state, - $window) { + $mmConfig, mmCoreSettingsRichTextEditor, $rootScope, $ionicPlatform, $ionicHistory, mmCoreSplitViewBlock, $state) { $log = $log.getInstance('$mmUtil'); @@ -2028,39 +2027,6 @@ angular.module('mm.core') } }; - /** - * Check if an element is outside of screen (viewport). - * - * @module mm.core - * @ngdoc method - * @name $mmUtil#isElementOutsideOfScreen - * @param {Object} element DOM element to check. - * @param {String} [scrollSelector] Selector to find the scroll that contains the element. - * @return {Boolean} Whether the element is outside of the viewport. - */ - self.isElementOutsideOfScreen = function(element, scrollSelector) { - scrollSelector = scrollSelector || '.scroll-content'; - - var elementRect = element.getBoundingClientRect(), - elementMidPoint, - scrollEl = self.closest(element, scrollSelector), - scrollElRect, - scrollTopPos = 0; - - if (!elementRect) { - return false; - } - - elementMidPoint = (Math.round(elementRect.bottom) + Math.round(elementRect.top)) / 2; - - if (scrollEl) { - scrollElRect = scrollEl.getBoundingClientRect(); - scrollTopPos = (scrollElRect && scrollElRect.top) || 0; - } - - return elementMidPoint > $window.innerHeight || elementMidPoint < scrollTopPos; - }; - return self; }; }); diff --git a/www/core/main.js b/www/core/main.js index a3aebaeb988..0e7e71188d2 100644 --- a/www/core/main.js +++ b/www/core/main.js @@ -175,7 +175,7 @@ angular.module('mm.core', ['pascalprecht.translate']) }) .run(function($ionicPlatform, $ionicBody, $window, $mmEvents, $mmInitDelegate, mmCoreEventKeyboardShow, mmCoreEventKeyboardHide, - $mmApp, $timeout, mmCoreEventOnline, mmCoreEventOnlineStatusChanged, $mmUtil, $ionicScrollDelegate) { + $mmApp, $timeout, mmCoreEventOnline, mmCoreEventOnlineStatusChanged) { // Execute all the init processes. $mmInitDelegate.executeInitProcesses(); @@ -190,20 +190,6 @@ angular.module('mm.core', ['pascalprecht.translate']) // Listen for keyboard events. We don't use $cordovaKeyboard because it doesn't support keyboardHeight property. $window.addEventListener('native.keyboardshow', function(e) { $mmEvents.trigger(mmCoreEventKeyboardShow, e); - - if (ionic.Platform.isIOS()) { - // In iOS the user can select elements outside of the view using previous/next. Check if it's the case. - if ($mmUtil.isElementOutsideOfScreen(document.activeElement)) { - // Focused element is outside of the screen. Scroll so the element is seen. - var position = $mmUtil.getElementXY(document.activeElement); - if (position) { - if ($window && $window.innerHeight) { - position[1] = position[1] - $window.innerHeight * 0.5; - } - $ionicScrollDelegate.scrollTo(position[0], position[1]); - } - } - } }); $window.addEventListener('native.keyboardhide', function(e) { $mmEvents.trigger(mmCoreEventKeyboardHide, e);