Home > Web Front-end > H5 Tutorial > How to solve the problem of sliding lag on the mobile terminal in h5

How to solve the problem of sliding lag on the mobile terminal in h5

王林
Release: 2020-11-24 16:27:42
forward
7280 people have browsed it

How to solve the problem of sliding lag on the mobile terminal in h5

The solution is as follows:

(Related video recommendations: html video tutorial)

1. ios side The -webkit-overflow-scrolling attribute can control the page scrolling effect. The settings are as follows to achieve inertial scrolling and elastic effects:

body{
-webkit-overflow-scrolling: touch;
overflow-scrolling: touch;
overflow-y: scroll;
}
Copy after login

2. Caused by the box setting a height of 100%:

html,body{
height: 100%;
}
Copy after login

Replace the above Just delete the code.

3, If neither of these two methods works, there is another solution, which is to use the area sliding component in the mui component

<div class="mui-scroll-wrapper">
	<div class="mui-scroll">
		<!--这里放置真实显示的DOM内容-->
	</div>
</div>
<script>
mui(&#39;.mui-scroll-wrapper&#39;).scroll({
       scrollY: true, //是否竖向滚动
       scrollX: false, //是否横向滚动
       startX: 0, //初始化时滚动至x
       startY: 0, //初始化时滚动至y
       indicators: true, //是否显示滚动条
       deceleration:0.0006, //阻尼系数,系数越小滑动越灵敏
       bounce: true //是否启用回弹
});
</script>
Copy after login

Configure the value in scroll according to your actual situation.

Note: bounce: true must be true. If changed to false, the entire page will not be able to slide

Related recommendations: h5

The above is the detailed content of How to solve the problem of sliding lag on the mobile terminal in h5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template