javascript - scrollIntoView 行为平滑不适用于第 8 代 Ipad
问题描述
我尝试了多种解决方案来在 iPad 8th gen 上实现流畅的行为。像iscroll,react scroll和自定义 polyfill 滚动一样,但行为是即时的而不是平滑的。
点击按钮:
<div className="mt-4 text-center mt-md-5 btn-hide">
<Button className="btn-see-more btn-outline-light Event Based" size="lg" onClick={() =>
executeScroll()}>
{constants.SEE_MORE_BTN}
</Button>
</div>
当我在按钮单击时调用滚动功能时,滚动行为在 Windows 上是平滑的,但是当我在 ipad 8th gen 上测试相同的滚动时,滚动行为是即时的。
const executeScroll = () => {
const element = document.getElementById('discoverEvents');
if (element) {
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
};
解决方案
推荐阅读
- sql - 有没有办法用 '(NOT) IN' 而不是 'NOT EXISTS' 重写这个 SQL 查询?
- angular - 离子路由器链接不重定向
- javascript - 从子级清除父级状态
- php - 当我创建了验证电话号码时,我也得到了这样的
- html - 为什么我们在应用 flex 和 grid 的属性时在 CSS 中使用大于号?
- ansible - 包含有条件的任务文件 - 任务仍在尝试运行?
- angular - 访问嵌套 FormGroup 中的 FormArray 以动态创建
- python - 解释区间 [0, 1] 中明显关系的舍入方向的惊人奇偶性
- c# - 从postgres中的json列中提取json数组数据
- java - 来自配置文件的依赖注入返回 null