美化滚动条 微小JavaScript插件 完美 滚动条

  • 源码大小:223.93KB
  • 所需积分:1积分
  • 源码编号:19JP-3653
  • 浏览次数:701次
  • 最后更新:2023年07月06日
  • 所属栏目:其他
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

完美的滚动条是一个轻量级的jQueryJavaScript插件,允许您在不更改或添加任何原始元素样式的情况下美化默认滚动条。

有了完美的滚动条插件,您页面上的滚动条可以完全自定义并灵活地满足您的需求

您可能还喜欢:

  • 自定义滚动条的jQuery插件-滚动框
  • jQuery自定义滚动条插件-malihu
  • 响应式浏览器滚动条替换插件-ClassyScroll
  • 类似Facebook的jQuery滚动条插件-slimScroll
  • nanoScroller-Mac OS X Lion风格的滚动条

如何使用它:

1.在文档中包含完美滚动条的CSS文件。

  1. <link href="min/perfect-scrollbar.min.css" rel="stylesheet">

2.HTML结构。

  1. <div id="demo">
    <div class="content"> </div>
    </div>

3.在页面底部包含必要的javascript文件。

  1. <script src="min/perfect-scrollbar.min.js"></script>

4.调用顶部容器上的插件并完成。

  1. new PerfectScrollbar('#demo', {
  2. // options here
  3. });

5.选项和默认值。

  1. new PerfectScrollbar('#demo', {
  2.  
  3. // A list of handlers to scroll the element.
  4. handlers: ['click-rail', 'drag-thumb', 'keyboard', 'wheel', 'touch'],
  5.  
  6. // 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.
  7. scrollingThreshold: 1000,
  8.  
  9. // The scroll speed applied to mousewheel event.
  10. wheelSpeed: 1,
  11.  
  12. // If true, when the scroll reaches the end of the side,
  13. // mousewheel event will be propagated to parent element.
  14. wheelPropagation: false,
  15.  
  16. // When set to an integer value, the thumb part of the scrollbar
  17. // will not shrink below that number of pixels.
  18. minScrollbarLength: null,
  19.  
  20. // When set to an integer value, the thumb part of the scrollbar
  21. // will not expand over that number of pixels.
  22. maxScrollbarLength: null,
  23.  
  24. // When set to true, and only one (vertical or horizontal) scrollbar
  25. // is visible then both vertical and horizontal scrolling will affect the scrollbar.
  26. useBothWheelAxes: false,
  27.  
  28. // When set to true, the scroll bar in X axis will not be available,
  29. // regardless of the content width.
  30. suppressScrollX: false,
  31.  
  32. // When set to true, the scroll bar in Y axis will not be available,
  33. // regardless of the content height.
  34. suppressScrollY: false,
  35.  
  36. // true: swipe scrolling will be eased
  37. swipeEasing: true,
  38.  
  39. // The number of pixels the content width can surpass the
  40. // container width without enabling the X axis scroll bar.
  41. scrollXMarginOffset: 0,
  42.  
  43. // The number of pixels the content height can surpass the
  44. // container height without enabling the Y axis scroll bar.
  45. scrollYMarginOffset: 0
  46.  
  47. });

6.事件处理程序。

  1. // fired when the x-axis is scrolled in either direction
  2. container.addEventListener('ps-scroll-x', () => ...);
  3.  
  4. // fired when the y-axis is scrolled in either direction
  5. container.addEventListener('ps-scroll-y', () => ...);
  6.  
  7. // fired when scrolling upwards
  8. container.addEventListener('ps-scroll-up', () => ...);
  9.  
  10. // fired when scrolling downward
  11. container.addEventListener('ps-scroll-down', () => ...);
  12.  
  13. // fired when scrolling to the left
  14. container.addEventListener('ps-scroll-left', () => ...);
  15.  
  16. // fired when scrolling to the right
  17. container.addEventListener('ps-scroll-right', () => ...);
  18.  
  19. // fired when scrolling reaches the start of the x-axis.
  20. container.addEventListener('ps-x-reach-start', () => ...);
  21.  
  22. // fired when scrolling reaches the end of the x-axis
  23. container.addEventListener('ps-x-reach-end', () => ...);
  24.  
  25. // fired when scrolling reaches the start of the y-axis.
  26. container.addEventListener('ps-y-reach-start', () => ...);
  27.  
  28. // fired when scrolling reaches the end of the y-axis (useful for infinite scroll)
  29. 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)

  • 修复:滚动条持续向下滚动超过内容长度
  • 修复:“无法读取null的属性”scrollTop“”

v1.5.0 (2020-01-16)

  • 使用汇总重新创建生成工具
  • 已将所有依赖项更新为最新版本
  • 从Travis CI切换到GitHub操作
  • 增加了可靠度,使我们的依赖关系保持最新
  • 固定RTL支持
  • 修正了mouse-wheel.js中的shouldBeConsumedByChild逻辑
  • 改进了与父类的兼容性
  • 在类型定义中添加了缺少的属性
  • 增加了对滚动元素的分数大小的支持
  • 增加了对触摸设备的支持
  • 增加了对移动设备的拖动支持

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)

  • 与iframes兼容。
  • 添加int()helper而不是parseInt。

版本0.5.2(2014-9-28)

  • 使现代化

版本0.5.1(2014-9-16)

  • Firefox和IE 10的鼠标滚轮修复程序。

版本0.4.11(2014-8-25)

  • 删除jquery鼠标滚轮依赖项。

版本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)

  • 在滚动条轨道上添加点击处理程序以滚动到该位置。
  • 添加“useBothWheelAxes”选项的示例。
  • 实现键盘滚动。

版本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)

  • 错误修复。
  • 包括带有jquery鼠标滚轮的最低版本。

 

预览截图