如何在"ios contenteditable element"中恢复格式文本后的平滑滚动?

BG *_*uno 6 html javascript contenteditable mobile-webkit ios

我想在#ios上的"contenteditable element"中编辑内容.在那个元素是更多的文字.

脚步

  1. 我顺利滚动到所选文本
  2. 我触摸元素和打开键盘
  3. 我触摸并选择多行文本并将其格式化为粗体
  4. 我现在想要滚动内容,但它不再流畅

这是可播放的代码:https:
//console.webcloud.io/profile/bruno.onlyme@gmail.com/_playwithcode/contenteditable-scroll-after-format/index.html

视频预览在这里.

<html>

<head>
    
    <meta name="viewport" content="width=device-width,minimum-scale=1,maximum-scale=1,user-scalable=no">
    
    <style>
        
        body {
            font-size: 24px;
        }
        
    </style>

</head>

<body>
    
    <button>button</button> | <a onclick="console.log();">anchor</a><br>
    <br>
    
    <div contenteditable>
        What is Lorem Ipsum?
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
        
        Why do we use it?
        It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
    </div>
    <br>
    
    <button>button</button> | <a onclick="console.log();">anchor</a>
    
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

经过大规模的调查后,我发现这个问题出现在S CH FF中,Opera以某种方式解决了这个问题,但却无法正常工作.这个问题出现在每个已知的编辑器#ckeditor5 #medium #alloyeditor中.

"平滑滚动"仅在2个条件下恢复

  1. 如果键盘被隐藏并通过触摸反复打开任何"可信任的元素"
  2. 如果我触摸任何其他"可点击元素"

测试中

  • NOK iphoneX ios11.4
  • NOK iphone6 ios11.4
  • NOK iphone6 ios11.3.1
  • NOK iphone5s ios11.4
  • 好的iphone5s ios11.3.1
  • 好的iphoneSE ios11.4
  • 好的iphoneSE ios9.3.2

INFO @ 31.05.2018 - 苹果虫报告但没有回复

INFO @ 15.06.2018 - 新触发事件 - 选择更多行 https://bugs.webkit.org/show_bug.cgi?id=186333#c2

INFO @ 25.06.2018 - 我创建了一个新的测试,其中#contenteditable在#iframe内部并且"smooth scroll"只有在我打开#keyboard向上滚动后才能工作,然后我可以格式化,仍然在平滑滚动之后 - 关闭键盘后重新打开它不起作用 - 我认为所有关于"虚拟空间"的"键盘创建",它需要某种"刷新尺寸".

问有没有人知道如何保持"平滑滚动"?

小智 0

我不确定这是否与您的问题有关,但我正在 iPhone SE 上的 iOS 9.3.2(我知道它很旧)上运行该网站,它对我来说工作得很好。

不仅在键盘关闭时网站滚动流畅,而且在键盘打开和选择文本时网站滚动也流畅。我也在手机上的 Safari 和 Google Chrome 中多次测试了这个过程。

这可能不是一个有用的答案(因为我是 StackOverflow 的新手,我不知道这样的答案是否也有帮助),但我想,作为反馈,它可能会对您有所帮助。