完美的滚动条是一个轻量级的jQueryJavaScript插件,允许您在不更改或添加任何原始元素样式的情况下美化默认滚动条。
有了完美的滚动条插件,您页面上的滚动条可以完全自定义并灵活地满足您的需求
1.在文档中包含完美滚动条的CSS文件。
<link href="min/perfect-scrollbar.min.css" rel="stylesheet">
2.HTML结构。
<div id="demo">
<div class="content"> </div>
</div>
3.在页面底部包含必要的javascript文件。
<script src="min/perfect-scrollbar.min.js"></script>
4.调用顶部容器上的插件并完成。
new PerfectScrollbar('#demo', {
// options here
});5.选项和默认值。
new PerfectScrollbar('#demo', {
// A list of handlers to scroll the element.
handlers: ['click-rail', 'drag-thumb', 'keyboard', 'wheel', 'touch'],
// This sets threshold for ps--scrolling-x and ps--scrolling-y classes to remain. In the default CSS, they make scrollbars shown regardless of hover state. The unit is millisecond.
scrollingThreshold: 1000,
// The scroll speed applied to mousewheel event.
wheelSpeed: 1,
// If true, when the scroll reaches the end of the side,
// mousewheel event will be propagated to parent element.
wheelPropagation: false,
// When set to an integer value, the thumb part of the scrollbar
// will not shrink below that number of pixels.
minScrollbarLength: null,
// When set to an integer value, the thumb part of the scrollbar
// will not expand over that number of pixels.
maxScrollbarLength: null,
// When set to true, and only one (vertical or horizontal) scrollbar
// is visible then both vertical and horizontal scrolling will affect the scrollbar.
useBothWheelAxes: false,
// When set to true, the scroll bar in X axis will not be available,
// regardless of the content width.
suppressScrollX: false,
// When set to true, the scroll bar in Y axis will not be available,
// regardless of the content height.
suppressScrollY: false,
// true: swipe scrolling will be eased
swipeEasing: true,
// The number of pixels the content width can surpass the
// container width without enabling the X axis scroll bar.
scrollXMarginOffset: 0,
// The number of pixels the content height can surpass the
// container height without enabling the Y axis scroll bar.
scrollYMarginOffset: 0
});6.事件处理程序。
// fired when the x-axis is scrolled in either direction
container.addEventListener('ps-scroll-x', () => ...);
// fired when the y-axis is scrolled in either direction
container.addEventListener('ps-scroll-y', () => ...);
// fired when scrolling upwards
container.addEventListener('ps-scroll-up', () => ...);
// fired when scrolling downward
container.addEventListener('ps-scroll-down', () => ...);
// fired when scrolling to the left
container.addEventListener('ps-scroll-left', () => ...);
// fired when scrolling to the right
container.addEventListener('ps-scroll-right', () => ...);
// fired when scrolling reaches the start of the x-axis.
container.addEventListener('ps-x-reach-start', () => ...);
// fired when scrolling reaches the end of the x-axis
container.addEventListener('ps-x-reach-end', () => ...);
// fired when scrolling reaches the start of the y-axis.
container.addEventListener('ps-y-reach-start', () => ...);
// fired when scrolling reaches the end of the y-axis (useful for infinite scroll)
container.addEventListener('ps-y-reach-end', () => ...);v1.5.5 (2022-03-24)
v1.5.3 (2021-10-25)
v1.5.2 (2021-07-19)
v1.5.1 (2021-05-04)
v1.5.0 (2020-01-16)
v1.4.0 (2019-12-03)
v1.4.0 (2018-06-07)
2018-04-09
v1.3.2 (2017-12-01)
版本0.5.8(2014-12-02)
版本0.5.7(2014-11-06)
版本0.5.6(2014-10-29)
版本0.5.5(2014-10-24)
版本0.5.4(2014-10-22)
版本0.5.3(2014-10-14)
版本0.5.2(2014-9-28)
版本0.5.1(2014-9-16)
版本0.4.11(2014-8-25)
版本0.4.10(2014-4-28)
版本0.4.9(2014-4-2)
版本0.4.8(2014-1-22)
版本0.4.7(2014-1-21)
版本0.4.6(2013-12-6)
版本0.4.5(2013-10-1)
版本0.4.4(2013-9-9)
版本0.4.1(2013-5-18)
版本0.3.4(2013-5-18)
版本0.3.3(2013-3-14)
版本0.2.5(2013-2-8)
Â