当前位置:网站首页>Mobile phone side scroll to page to specify location
Mobile phone side scroll to page to specify location
2022-07-30 07:52:00 【cplvfx】
scrollIntoViewOptions is very useful, but currently only supported by Chrome and FireFox, but can be implemented by other plugins (smoothscroll-polyfill)span>
Example
document.getElementById('content').scrollIntoView({block: 'start',inline: 'nearest',behavior: 'smooth'})Documentation
The first solution: the method parameter is passed "alignToTop"
Previously this parameter was well supported
scrollIntoView(alignToTop); // Boolean parameteralignToTop
A Boolean value:
- If true, the top of the element will be aligned with the top of the visible area of the scroll area it is in.
- If false, the bottom of the element will be aligned with the bottom of the visible area of the scroll area it is in.
true : The top of the element will be aligned to the top of the scrollable ancestor's visible area.Corresponds to scrollIntoViewOptions: {block: "start", inline: "nearest"} which is the defaultfalse: The bottom of the element will be aligned with the bottom of the scrollable ancestor's visible area.Corresponds to scrollIntoViewOptions: {block: "end", inline: "nearest"}.Use
document.getElementById('content').scrollIntoView(true);The second solution (such as the example): pass "scrollIntoViewOptions" as a method parameter
Currently this parameter browser does not support it well, you can check the compatibility below
element.scrollIntoView(scrollIntoViewOptions); // Object parameterbehavior: [Optional] Define the transition animation."auto", "instant" or "smooth".Defaults to "auto".block : [optional] "start" (top), "center" (center), "end" (tail) or "nearest".Defaults to "center".inline: [optional] "start", "center", "end" or "nearest".Defaults to "nearest".
Use
document.getElementById('content').scrollIntoView({block: 'start',inline: 'nearest',behavior: 'smooth'})Reference
http://mssn.midea.com/ask/?/article/230
https://zhuanlan.zhihu.com/p/342205449
边栏推荐
- MySQL什么时候用表锁,什么时候用行锁?
- MongoDB-CUD without R
- Test Development Engineer Growth Diary 007 - Bug Priority Definition and Filling Specifications
- Vineyard: An open source distributed in-memory data management framework
- RAID磁盘阵列
- flask项目快速搭建部署gunicorn+supervisor
- 测开基础知识01
- 相机坐标系,世界坐标系,像素坐标系三者转换,以及OPENGLDEFocal Length和Opengl 的 Fov转换
- Rapidly develop GraphScope graph analysis applications
- 手机端滚动至页面指定位置
猜你喜欢

MySQL什么时候用表锁,什么时候用行锁?

Huawei released "ten inventions", including computing, intelligent driving and other new fields

prometheus监控mysql

DHCP principle and configuration

As a test leader, examine several aspects of job candidates

idea built-in translation plugin
测试开发工程师成长日记010 - Jenkins中的CI/CD/CT(持续集成构建/持续交付/持续测试)

Mastering JESD204B (1) – Debugging of AD6676

《心智社会》—马文·明斯基

Redis6的数据类型
随机推荐
进程和计划任务管理
MySql connecting to the server remotely
阿里二面:列出 Api 接口优化的几个技巧
numpy 多维数组ndarray的详解
从 Vertex 到 Subgraph 再到 PIE: 并行图计算编程模型概览
Test the basics 02
矩阵的行列式的计算及其源码
Test Development Engineer Growth Diary 007 - Bug Priority Definition and Filling Specifications
测试开发工程师成长日记017 - bug的生命周期
Detailed explanation of numpy multidimensional array ndarray
让百度地图生成器里的“标注”内容展开--解决方案
测试开发工程师成长日记018 - 测试面试必备题记录(持续更新)
PXE efficient mass network capacity
测试开发工程师成长日记016 - 关于提测的那些事
软件测试_01
libgrape-lite: 提供 GraphScope 的图分析能力
prometheus-basic_auth加密配置
多线程基础(多线程内存,安全,通信,线程池和阻塞队列)
新人误删数据,组长巧用MySQL主从复制延迟挽回损失
DHCP原理与配置