1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-22 15:02:51 +02:00

Updated scroll-to-selection to abort only if on iOS 11

This commit is contained in:
Sunny Hirai
2018-01-10 16:57:39 -08:00
parent d96a528ac0
commit 7dee55d066

View File

@@ -51,6 +51,19 @@ function findScrollContainer(el, window) {
return scroller 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. * Scroll the current selection's focus point into view if needed.
* *
@@ -58,7 +71,11 @@ function findScrollContainer(el, window) {
*/ */
function scrollToSelection(selection) { function scrollToSelection(selection) {
if (IS_IOS) return if (IS_IOS) {
const majorIOSVersion = getMajorIOSVersion()
if (majorIOSVersion && majorIOSVersion == 11) return
}
if (!selection.anchorNode) return if (!selection.anchorNode) return
const window = getWindow(selection.anchorNode) const window = getWindow(selection.anchorNode)