1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 13:11:17 +02:00

Updated scroll-to-selection so it skips the scroll only on version 11 of iOS.

This commit is contained in:
Sunny Hirai
2018-01-11 10:06:41 -08:00
parent 69e53cb556
commit 3d86533b5b

View File

@@ -15,6 +15,12 @@ const OVERFLOWS = [
'scroll',
]
/**
* Detect whether we are running IOS version 11
*/
const IS_IOS_11 = IS_IOS && !!window.navigator.userAgent.match(/os 11_/i)
/**
* Find the nearest parent with scrolling, or window.
*
@@ -51,19 +57,6 @@ function findScrollContainer(el, window) {
return scroller
}
/**
* Get the current iOS version. Assumes that an IOS check was conducted
* prior to calling.
*/
const IOS_VERSION_REGEX = /OS (\d+)_/
function getMajorIOSVersion() {
const { userAgent } = window.navigator
const matches = userAgent.match(IOS_VERSION_REGEX)
return matches ? parseInt(matches[1]) : null
}
/**
* Scroll the current selection's focus point into view if needed.
*
@@ -71,11 +64,7 @@ function getMajorIOSVersion() {
*/
function scrollToSelection(selection) {
if (IS_IOS) {
const majorIOSVersion = getMajorIOSVersion()
if (majorIOSVersion && majorIOSVersion == 11) return
}
if (IS_IOS_11) return
if (!selection.anchorNode) return
const window = getWindow(selection.anchorNode)