-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scrollIntoViewIfNeeded 与 scrollIntoView #3
Comments
根据MDN文档,
其实这两个特性,我个人感觉应用最多的场景应该是在移动端,当表单元素获得焦点的时候滚动到视野中,避免软键盘遮挡元素。鉴于 虽然MDN文档中说 但是反观 根据上面的比较应该可以得出结论:在移动避免软键盘遮挡表单元素时,应该使用 以上。 如有错误,敬请指正。 |
@Tao-Quixote 是的,这个主要是用在移动端,而且推荐使用 |
@Yangfan2016 |
soga thx ~ |
MDN 文档:
Element.scrollIntoView()
方法让当前的元素滚动到浏览器窗口的可视区域内。而Element.scrollIntoViewIfNeeded()
是Element.scrollIntoView()
的变体,如果该元素已经在浏览器窗口的可见区域内,则不会发生滚动。Element.scrollIntoView()
,无论设置什么参数,均发生滚动。Element.scrollIntoViewIfNeeded()
,无论设置什么参数,均不发生滚动。The text was updated successfully, but these errors were encountered: