Skip to content

Commit 467771a

Browse files
committed
Revert "MOBILE-1849 ios: Scroll if focused element is outside of screen"
This reverts commit 419375f.
1 parent 3ddeddb commit 467771a

File tree

2 files changed

+2
-50
lines changed

2 files changed

+2
-50
lines changed

www/core/lib/util.js

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ angular.module('mm.core')
6868

6969
this.$get = function($ionicLoading, $ionicPopup, $injector, $translate, $http, $log, $q, $mmLang, $mmFS, $timeout, $mmApp,
7070
$mmText, mmCoreWifiDownloadThreshold, mmCoreDownloadThreshold, $ionicScrollDelegate, $mmWS, $cordovaInAppBrowser,
71-
$mmConfig, mmCoreSettingsRichTextEditor, $rootScope, $ionicPlatform, $ionicHistory, mmCoreSplitViewBlock, $state,
72-
$window) {
71+
$mmConfig, mmCoreSettingsRichTextEditor, $rootScope, $ionicPlatform, $ionicHistory, mmCoreSplitViewBlock, $state) {
7372

7473
$log = $log.getInstance('$mmUtil');
7574

@@ -2028,39 +2027,6 @@ angular.module('mm.core')
20282027
}
20292028
};
20302029

2031-
/**
2032-
* Check if an element is outside of screen (viewport).
2033-
*
2034-
* @module mm.core
2035-
* @ngdoc method
2036-
* @name $mmUtil#isElementOutsideOfScreen
2037-
* @param {Object} element DOM element to check.
2038-
* @param {String} [scrollSelector] Selector to find the scroll that contains the element.
2039-
* @return {Boolean} Whether the element is outside of the viewport.
2040-
*/
2041-
self.isElementOutsideOfScreen = function(element, scrollSelector) {
2042-
scrollSelector = scrollSelector || '.scroll-content';
2043-
2044-
var elementRect = element.getBoundingClientRect(),
2045-
elementMidPoint,
2046-
scrollEl = self.closest(element, scrollSelector),
2047-
scrollElRect,
2048-
scrollTopPos = 0;
2049-
2050-
if (!elementRect) {
2051-
return false;
2052-
}
2053-
2054-
elementMidPoint = (Math.round(elementRect.bottom) + Math.round(elementRect.top)) / 2;
2055-
2056-
if (scrollEl) {
2057-
scrollElRect = scrollEl.getBoundingClientRect();
2058-
scrollTopPos = (scrollElRect && scrollElRect.top) || 0;
2059-
}
2060-
2061-
return elementMidPoint > $window.innerHeight || elementMidPoint < scrollTopPos;
2062-
};
2063-
20642030
return self;
20652031
};
20662032
});

www/core/main.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ angular.module('mm.core', ['pascalprecht.translate'])
175175
})
176176

177177
.run(function($ionicPlatform, $ionicBody, $window, $mmEvents, $mmInitDelegate, mmCoreEventKeyboardShow, mmCoreEventKeyboardHide,
178-
$mmApp, $timeout, mmCoreEventOnline, mmCoreEventOnlineStatusChanged, $mmUtil, $ionicScrollDelegate) {
178+
$mmApp, $timeout, mmCoreEventOnline, mmCoreEventOnlineStatusChanged) {
179179
// Execute all the init processes.
180180
$mmInitDelegate.executeInitProcesses();
181181

@@ -190,20 +190,6 @@ angular.module('mm.core', ['pascalprecht.translate'])
190190
// Listen for keyboard events. We don't use $cordovaKeyboard because it doesn't support keyboardHeight property.
191191
$window.addEventListener('native.keyboardshow', function(e) {
192192
$mmEvents.trigger(mmCoreEventKeyboardShow, e);
193-
194-
if (ionic.Platform.isIOS()) {
195-
// In iOS the user can select elements outside of the view using previous/next. Check if it's the case.
196-
if ($mmUtil.isElementOutsideOfScreen(document.activeElement)) {
197-
// Focused element is outside of the screen. Scroll so the element is seen.
198-
var position = $mmUtil.getElementXY(document.activeElement);
199-
if (position) {
200-
if ($window && $window.innerHeight) {
201-
position[1] = position[1] - $window.innerHeight * 0.5;
202-
}
203-
$ionicScrollDelegate.scrollTo(position[0], position[1]);
204-
}
205-
}
206-
}
207193
});
208194
$window.addEventListener('native.keyboardhide', function(e) {
209195
$mmEvents.trigger(mmCoreEventKeyboardHide, e);

0 commit comments

Comments
 (0)