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

Merge pull request #1515 from thesunny/ios-fix

Fixed scroll-to-selection jumping to top on iOS 11
This commit is contained in:
Sunny Hirai
2018-01-11 15:41:53 -08:00
committed by GitHub

View File

@@ -1,7 +1,7 @@
import getWindow from 'get-window'
import isBackward from 'selection-is-backward'
import { IS_SAFARI } from '../constants/environment'
import { IS_SAFARI, IS_IOS } from '../constants/environment'
/**
* CSS overflow values that would cause scrolling.
@@ -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.
*
@@ -58,6 +64,7 @@ function findScrollContainer(el, window) {
*/
function scrollToSelection(selection) {
if (IS_IOS_11) return
if (!selection.anchorNode) return
const window = getWindow(selection.anchorNode)