mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 06:01:24 +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:
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import getWindow from 'get-window'
|
import getWindow from 'get-window'
|
||||||
import isBackward from 'selection-is-backward'
|
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.
|
* CSS overflow values that would cause scrolling.
|
||||||
@@ -15,6 +15,12 @@ const OVERFLOWS = [
|
|||||||
'scroll',
|
'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.
|
* Find the nearest parent with scrolling, or window.
|
||||||
*
|
*
|
||||||
@@ -58,6 +64,7 @@ function findScrollContainer(el, window) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function scrollToSelection(selection) {
|
function scrollToSelection(selection) {
|
||||||
|
if (IS_IOS_11) return
|
||||||
if (!selection.anchorNode) return
|
if (!selection.anchorNode) return
|
||||||
|
|
||||||
const window = getWindow(selection.anchorNode)
|
const window = getWindow(selection.anchorNode)
|
||||||
|
Reference in New Issue
Block a user