一个自定义滚动条npm包,实现原生滚动条的绝大

sjf-scroll

A simple custom scroll npm package. It is made according to the browser's scroll bar. So it can support most browser's feature.For example, it supports the mousewheel, drag and click event etc.

Usage

Install the npm package

npm install sjf-scroll

Add the script to initialize sjfScroll after dom onloaded

import sjfScroll from 'sjf-scroll' sjfScroll.initScroll()

Add the entrance of the sjf-scroll.

* The sjfScroll.js is to search the element with the attribute of 'sjf-scroll'. And rewriting the dom structure to realize the function * The attribute `max-height` is set to show the scroll bar when sjf-scroll content's height beyond it. * The default value of attribute `max-height` is 150 and the value you set best to greater than or equal to 150 options

The sjf-scroll supports options for users to set

{ delay: 1000, // default value gradient: 10 // default value minHeight: 30 // default value }

The option delay is to set the time the mouse is suspended in the sjf-scroll before executing other events (鼠标停留在sjf-scroll多久才会执行滚轮事件或者键盘事件)

The option gradient is to set the change unit of wheel or keydown events (滚一下滚动10px或者上翻10px)

The option minHeight is to set the min height of the sjf-scroll-content(the part is to show the progress of scroll)

the user to set the options API is sjfScroll.setOptions(param)

the param is a object which contains one attribute or more of options

the user can load some other thing through the sjfScroll.scroll to set the function of callback

And now you can use sjf-scroll in your project easily

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。