原文地址

https://github.com/noraesae/perfect-scrollbar

perfect-scrollbar

Tiny but perfect jQuery scrollbar plugin

Why perfect-scrollbar?

I worked on a personal project recently, and I was trying to find the jQuery scrollbar plugin that's perfect. But there was no perfect scrollbar plugin. That's why I decided to make one.

perfect-scrollbar is very tiny but perfect (for me, and maybe for the most of developers) jQuery scrollbar plugin.
I hope you love this!

Demo: http://noraesae.github.com/perfect-scrollbar/

What does perfect mean?

perfect means...

  • There should be no css change on any original element.
  • The scrollbar should not affect the original design layout.
  • The design of the scrollbar should be (nearly) fully customizable.
  • If the size of the container or the content changes, the scrollbar size and position should be able to change.

Then perfect-scrollbar is really perfect?

Yes! the only thing that's not perfect is my English.

  • perfect-scrollbar has some requirements, but doesn't change or add any style on original elements.
  • perfect-scrollbar is designed not to have width or height. It's fixed on the right and bottom side of the container.
  • You can change nearly all css styles of the scrollbar. The scrollbar design has no dependency on scripts.
  • perfect-scrollbar support 'update' function. Whenever you need to update the size or position of the scrollbar, just update.
  • Additionally, perfect-scrollbar do use 'scrollTop' and 'scrollLeft', not absolute position or something messy.

It's cool, isn't it?

Install

You can download the latest stable version with download links in Github Page. You also can find all releases inReleases page.

If you want to use the development version of the plugin, use the source files which are not minified. They're in the src directory. The development version may be unstable, but some known bugs can be fixed.

git clone https://github.com/noraesae/perfect-scrollbar.git
cd perfect-scrollbar/src

You can use Bower to install the plugin. The plugin is registered as perfect-scrollbar.

bower install perfect-scrollbar

Requirements

To make this plugin perfect, some requirements were not avoidable. But they're all very trivial and there's nothing to worry about.

  • the container must have a 'position' css style.
  • the container must have an 'overflow:hidden' css style.
  • the scrollbar's position must be 'absolute'.
  • the scrollbar-x must have a 'bottom' css style, and the scrollbar-y must have a 'right' css style.

The requirement below is for perfect-scrollbar <= 0.3.4

  • there must be the one content element(like div) for the container.

Optional parameters

perfect-scrollbar supports optional parameters.

wheelSpeed

The scroll speed applied to mousewheel event.
Default: 10

wheelPropagation

If this option is true, when the scroll reach the end of the side, mousewheel event will be propagated to parent element.
Currently not supported for touch events
Default: false

minScrollbarLength

When set to an integer value, the thumb part of the scrollbar will not shrink below that number of pixels.
Default: null

maxScrollbarLength

When set to an integer value, the thumb part of the scrollbar will not expand over that number of pixels.
Default: null

useBothWheelAxes

When set to true, and only one (vertical or horizontal) scrollbar is visible then both vertical and horizontal scrolling will affect the scrollbar.
Default: false

useKeyboard

When set to true, the scroll works with arrow keys on the keyboard. The element is scrolled only when the mouse cursor hovers the element.
Default: true

suppressScrollX

When set to true, the scroll bar in X axis will not be available, regardless of the content width.
Default: false

suppressScrollY

When set to true, the scroll bar in Y axis will not be available, regardless of the content height.
Default: false

scrollXMarginOffset

The number of pixels the content width can surpass the container width without enabling the X axis scroll bar. Allows some "wiggle room" or "offset break", so that X axis scroll bar is not enabled just because of a few pixels.
Default: 0

scrollYMarginOffset

The number of pixels the content height can surpass the container height without enabling the Y axis scroll bar. Allows some "wiggle room" or "offset break", so that Y axis scroll bar is not enabled just because of a few pixels.
Default: 0

includePadding

When set to true, it uses innerWidth and innerHeight for the container size instead of width and height. When your container element has non-zero padding and the scrollbar layout looks weird, this option can be helpful.
Default: false

How to Use

<style>
#Demo {
position: 'relative';
height: 100%; // Or whatever you want (eg. 400px)
overflow: hidden;
}
</style>
<div id='Demo'>
<div>
...
</div>
</div>

When the html document is like above, just use like this:

$('#Demo').perfectScrollbar();

With optional parameters:

$("#Demo").perfectScrollbar({
wheelSpeed: 20,
wheelPropagation: true,
minScrollbarLength: 20
})

If the size of your container or content changes:

$('#Demo').perfectScrollbar('update');

If you want to destory the scrollbar:

$('#Demo').perfectScrollbar('destroy');

If you want to scroll to somewhere, just use scroll-top css and update.

$("#Demo").scrollTop(0);
$("#Demo").perfectScrollbar('update');

Also you can get the informations about how to use the plugin from example codes in the examples directory of the source tree.

Very helpful friends

perfect-scrollbar supports jquery-mousewheel. If you want to use mousewheel features, please include jquery-mousewheel before using perfect-scrollbar.

If you want to make this plugin's update function more responsive, jquery-resize can be helpful.

Contribution

Please read Contributing in the wiki before making any contibution.

really welcome contributions! Please feel free to fork and issue pull requests when...

  • You have a very nice idea to improve this plugin!
  • You found a bug!
  • You're good at English and can help my bad English!

For IE problems, please refer to IE Support

IE Support

This plugin supports old IE browsers in the minimum range. The plugin is tested in IEs >= IE6 and works(not well, but works).

But the project will not accept the patches to fix IE problems in IE 6/7/8.

From jQuery 2.0, jQuery also will not support IE 6/7/8. I also think that supporting old browsers really breaks the web development conventions.

When old IEs should be supported, please fork the project and make patches personally.

Helpdesk

If you have any idea to improve this project or any problem using this, please feel free to upload an issue.

License

The MIT License (MIT) Copyright (c) 2012, 2014 Hyeonje Alex Jun and other contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

JQuery 滚动条插件perfect-scrollbar的更多相关文章

  1. Perfect Scrollbar – 完美的 jQuery 滚动条插件

    Perfect Scrollbar 是一个很小的,但完美的 jQuery 滚动插件.滚动条不会影响原来的设计布局,滚动条的设计是完全可定制的.你可以改变几乎所有的 CSS 样式的滚动条,滚动条设计对脚 ...

  2. 11 个最佳 jQuery 滚动条插件

    通过jQuery滚动条插件,你可以换掉千篇一律的默认浏览器滚动条,让你的网站或web项目更具特色,更有吸引力.本文收集了11款非常漂亮.实用的jQuery滚动条插件,你可以轻松将它们应用在自己的网站中 ...

  3. 原创新闻 11 个最佳 jQuery 滚动条插件

    通过jQuery滚动条插件,你可以换掉千篇一律的默认浏览器滚动条,让你的网站或web项目更具特色,更有吸引力.本文收集了11款非常漂亮.实用的jQuery滚动条插件,你可以轻松将它们应用在自己的网站中 ...

  4. jQuery滚动条插件 – jquery.slimscroll.js

    jquery.slimscroll.js插件是一个支持把内容放在一个盒子里面,固定一个高度,超出的则使用滚动.jquery.slimscroll.js不仅可以定义高度.宽度,还可以定义位置.滚动条大小 ...

  5. 超棒的自定义超酷滚动条jQuery插件 - Perfect Scrollbar

    可能大家厌倦了千篇一律的页面滚动条,如果你希望能够设计出与众不同的页面UI设计的话,Perfect ScrollBar可能就是你寻找的解决方案. 这个滚动条来自于一个个人项目,一个简单但是非常棒的滚动 ...

  6. 15个带示例的jQuery滚动条插件

    1.NiceScroll:可用于桌面.移动与触摸设备的jQuery滚动插件 NiceScroll是一个jQuery插件(since 1.5),它有着类似于ios/移动设备的样式.它支持Div.iFra ...

  7. 自定义滚动条jQuery插件- Perfect Scrollbar

    主要特性: 不需要修改任何的元素的css 滚动条不影响最初的页面布局设计 滚动条支持完整的自定义 滚动条的尺寸和位置会随着容器尺寸或者内容的变化而变化 依赖于jQuery和相关几个类库 不需要定义宽度 ...

  8. jquery滚动条插件nanoscroller的应用

    默认的滚动条的样式,各个版本的兼容性不是很好, 推荐一款jQuery 插件nanoscroller ,可以自定义滚动条的样式. 应用: 1.引入样式 nanoscroller.css <link ...

  9. jquery——滚动条插件jscroll.js

    一.效果如下 点击“测试中奖纪录”弹出弹框.弹框中内容超出时显示滚动条. 二.代码部分 1.html结构 <body> <a href="javascript:;" ...

随机推荐

  1. Linux中进行单文件内容的复制

    文件内容复制的常规方法: 开辟一段空间,不断读取文件的内容并写入另一文件当中,这种方法好在安全,一般在类型允许的最大范围内是安全的,缺点就是复制内容的时间长 一次性复制文件的内容,这种方法必须首先获取 ...

  2. 基于netty http协议栈的轻量级流程控制组件的实现

    今儿个是冬至,所谓“冬大过年”,公司也应景五点钟就放大伙儿回家吃饺子喝羊肉汤了,而我本着极高的职业素养依然坚持留在公司(实则因为没饺子吃没羊肉汤喝,只能呆公司吃食堂……).趁着这一个多小时的时间,想跟 ...

  3. .net 大型分布式电子商务架构说明

    .net大型分布式电子商务架构说明 背景 构建具备高可用,高扩展性,高性能,能承载高并发,大流量的分布式电子商务平台,支持用户,订单,采购,物流,配送,财务等多个项目的协作,便于后续运营报表,分析,便 ...

  4. 微信小程序前端源码逻辑和工作流

    看完微信小程序的前端代码真的让我热血沸腾啊,代码逻辑和设计一目了然,没有多余的东西,真的是大道至简. 废话不多说,直接分析前端代码.个人观点,难免有疏漏,仅供参考. 文件基本结构: 先看入口app.j ...

  5. WCF基础

    初入职场,开始接触C#,开始接触WCF,那么从头开始学习吧,边学边补充. SOA Service-Oriented Architecture,面向服务架构,粗粒度.开放式.松耦合的服务结构,将应用程序 ...

  6. Tomcat常见问题及常用命令

    很长时间不用tomcat好多命令都忘记了,所以准备自己记录下来,以便参考.刚好也希望可以开始养成记博客的好习惯. 1.查看java的版本号 进入java的安装目录后,使用命令:java -versio ...

  7. 设计模式C#合集--抽象工厂模式

    抽象工厂,名字就告诉你是抽象的了.上代码. public interface BMW { public void Drive(); } public class BMW730 : BMW { publ ...

  8. Oracle 分页

    --1:无ORDER BY排序的写法.(效率最高) --(经过测试,此方法成本最低,只嵌套一层,速度最快!即使查询的数据量再大,也几乎不受影响,速度依然!) SELECT * FROM (SELECT ...

  9. [高性能MYSQL 读后随笔] 关于事务的隔离级别(一)

    一.锁的种类 MySQL中锁的种类很多,有常见的表锁和行锁,也有新加入的Metadata Lock等等,表锁是对一整张表加锁,虽然可分为读锁和写锁,但毕竟是锁住整张表,会导致并发能力下降,一般是做dd ...

  10. PHP5.4~7.1新特性总结

    http://note.youdao.com/noteshare?id=7273b858fc12873ad092979e4ba173a7&sub=WEB334fdcf50b507ad93549 ...