https://github.com/noraesae/perfect-scrollbar
Tiny but perfect jQuery scrollbar plugin
I worked on a personal PRoject recently, and I was trying to find the jQuery scrollbar plugin that'sperfect. But there was noperfectscrollbar plugin. That's why I decided to make one.
perfect-scrollbar is very tiny butperfect(for me, and maybe for the most of developers) jQuery scrollbar plugin.I hope you love this!
Demo:http://noraesae.github.com/perfect-scrollbar/
perfectmeans...
Yes! the only thing that's notperfectis my English.
It's cool, isn't it?
You can download the latest stable version with download links inGithub Page. You also can find all releases inReleasespage.
If you want to use the development version of the plugin, use the source files which are not minified. They're in thesrc
directory. The development version may be unstable, but some known bugs can be fixed.
git clone https://github.com/noraesae/perfect-scrollbar.gitcd perfect-scrollbar/src
You can useBowerto install the plugin. The plugin is registered asperfect-scrollbar
.
bower install perfect-scrollbar
To make this pluginperfect, some requirements were not avoidable. But they're all very trivial and there's nothing to worry about.
The requirement below is for perfect-scrollbar <= 0.3.4
perfect-scrollbar supports optional parameters.
The scroll speed applied to mousewheel event.Default: 10
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 eventsDefault: false
When set to an integer value, the thumb part of the scrollbar will not shrink below that number of pixels.Default: null
When set to an integer value, the thumb part of the scrollbar will not expand over that number of pixels.Default: null
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
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
When set to true, the scroll bar in X axis will not be available, regardless of the content width.Default: false
When set to true, the scroll bar in Y axis will not be available, regardless of the content height.Default: false
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
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
When set to true, it usesinnerWidth
andinnerHeight
for the container size instead ofwidth
andheight
. When your container element has non-zero padding and the scrollbar layout looks weird, this option can be helpful.Default: false
<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 theexamples
directory of the source tree.
perfect-scrollbar supportsjquery-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-resizecan be helpful.
Ireallywelcome contributions! Please feel free to fork and issue pull requests when...
For IE problems, please refer toIE Support
This plugin supports old IE browsers in theminimumrange. 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.
If you have any idea to improve this project or any problem using this, please feel free to upload anissue.
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
新闻热点
疑难解答