Home  >  Article  >  Web Front-end  >  Detailed explanation of the use of scrolling plug-in for vue better-scroll

Detailed explanation of the use of scrolling plug-in for vue better-scroll

php中世界最好的语言
php中世界最好的语言Original
2018-04-12 17:18:524150browse

This time I will bring you a detailed explanation of the use of the vue better-scroll scrolling plug-in. What are the precautions when using the vue better-scroll scrolling plug-in. Here are practical cases, let’s take a look.

BetterScroll is known as the best mobile scrolling plug-in currently, so its power is definitely there. Otherwise...haha. Personally I feel it's very useful. This article is not about BetterScroll in general, but about scrolling in detail. If you want to learn more about it, please go here.

Rolling principle

What is better-scrollScrolling principle

better-scroll is a plug-in that focuses on solving the needs of various scrolling scenarios on the mobile side (PC already supported). Its core is based on the implementation of iscroll. Its API design is basically compatible with iscroll. On the basis of iscroll, it has expanded some features and made some performance optimization.

better-scroll is implemented based on native JS and does not rely on any framework. Its compiled code size is 63kb, 35kb after compression, and only 9kb after gzip. It is a very lightweight JS lib.

The green part is the wrapper, which is the parent container, and it will have a fixed height. The yellow part is content, which is the first child element of the parent container, its height will increase with the size of the content. Then, when content The height does not exceed the height of the parent container and cannot be scrolled. Once it exceeds the height of the parent container, we can scroll the content area. The principle of horizontal scrolling is to change the fixed height to a fixed width. (I won’t go into too much detail here)

Vertical scroll

Without further ado, let’s get straight to the code.



This is a Vue BetterScroll vertical scrolling demo. There are two points to note here.

  1. There can only be one layer of parent p, that is, the container

  2. The parent p must be set to overflow hiding and have a fixed height

Horizontal scroll

Horizontal scrolling, compared to vertical scrolling, requires dynamically obtaining the width of the scroll area and directly entering the code.


 
 

Side scrolling requires attention.

  1. There can only be one layer of parent p, that is, the container

  2. The parent container must set overflow hiding and fixed width

  3. Dynamicly obtain the width of the scroll area

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Full selection and inverse selection in vue

How to obtain it when using the mint-ui time plug-in Select value

The above is the detailed content of Detailed explanation of the use of scrolling plug-in for vue better-scroll. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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