Native JavaScript Scrolling Plugin (Original)

Add-ons
2026-07-25 23:16 3 次浏览 • 0 次下载 7.9KB
Native JavaScript Scrolling Plugin (Original)

Last Updated: 2021-03-08 21:55:16

Changelog:Fixed a bug in scrollbox percentage-based height settings and added logic to hide the scrollbar when the content height does not exceed the container height.


Last Updated: 2021-02-07 23:09:39

Usage

Step 1: Import CSS and JS

Step 2: Create four nested DOM elements

1
2
3
4
5
6
7
8
9
10
<div id="scrollbox"><div><div>
<div class="list">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
...
</div>
</div></div></div>

Step 3: For vertical scrolling, set the maximum height or height.

1
2
3
4
overflow: hidden;#scrollbox {
max - height: 600 px;
overflow: hidden;
}

Step 4: Create the scrollbar object

1
var oScrollbar = new TScrollBar('#scrollbox');

For horizontal scrolling, set the width during initialization.

1
2
3
4
var oScrollbar = new TScrollBar('#scrollbox', {
direction: 'horizontal',
width: 1000
});
星河码客

发现和分享优质开源项目,传承互联网精神,为开发者服务。

关于本站

联系我们

微信/广告合作:ITcloub (备注星河码客)

免责声明:本站资源版权归原作者所有,仅供学习与交流。如有侵权,请通过「关于我们 - 侵权投诉」联系删除。

Powered by Nuxt · Deployed on Cloudflare