Compare commits

...

59 Commits

Author SHA1 Message Date
Hyunje Alex Jun
7cf8303b30 Release 0.5.5.
1. Bug fixes.
2014-10-24 12:06:04 +01:00
Hyunje Alex Jun
7dd6335965 Filter touch events not to be handled.
In IE 10/11, MSPointer event is fired by mouse. It shouldn't be handled.

Also, Exception has occurred with event.targetTouches, and this commit
fixed it too.
2014-10-24 12:03:55 +01:00
Hyunje Alex Jun
494d68fe02 Merge pull request #231 from suxxes/patch-1
Correction for railBorderYWidth calculation
2014-10-22 16:10:07 +01:00
Fedor
3dde3ebb0c Correction for railBorderYWidth calculation 2014-10-22 17:09:45 +04:00
Hyunje Alex Jun
12086573fc Update README.md
Add `npm` to install section.
2014-10-21 21:43:07 +01:00
Hyunje Alex Jun
a98c77d160 Release 0.5.4
1. Inner scrollbar problem fix.
2. Inner scrollbar touch event problem fix.
3. Bug fixes.
2014-10-21 21:31:02 +01:00
Hyunje Alex Jun
48e1c688b2 Add additional information to package.json 2014-10-21 21:29:34 +01:00
Hyunje Alex Jun
991e664b18 Stop propagation and prevent default for touch events.
Fix #228.
2014-10-21 21:14:23 +01:00
Hyunje Alex Jun
ee4fc96b7a Bind touch handlers only when it's supported.
Fix #227.
2014-10-21 21:06:16 +01:00
Hyunje Alex Jun
664dec23d6 No longer support old IEs. 2014-10-21 20:58:43 +01:00
Hyunje Alex Jun
65869821c1 Use > CSS selector.
This patch will resolve inner scrollbar problems.
2014-10-21 20:53:55 +01:00
Hyunje Alex Jun
4f7595a34f Release 0.5.3.
1. Focusable element bug fix for ShadowDom element.
2. Int conversion enhancement.
3. Add IE Pointer handler.
4. Ctrl+Home/End support.
5. Iframe support.
2014-10-14 01:38:04 +01:00
Hyunje Alex Jun
97a44c29a8 Add grunt task to release new version. 2014-10-14 01:37:05 +01:00
Nicolás Moncada
467cdb17ed Adding an example using iframe. 2014-10-14 01:11:06 +01:00
Nicolás Moncada
6ac02fae2b It makes compatible with iframes. 2014-10-14 01:11:06 +01:00
Hyunje Alex Jun
d4ec7fca6d Merge pull request #219 from MathieuLorber/input-in-shadowdom
ShadowDom form elements are considered for preventing scrolling by keyevent
2014-10-14 01:46:03 +02:00
Gene Diaz Jr
0022bd5595 Added cdn information
mirror on cdnjs.com http://cdnjs.com/libraries/jquery.perfect-scrollbar

Modified by @noraesae, as I wouldn't want to update README every time
I bump up the version.
2014-10-14 00:39:09 +01:00
Hyunje Alex Jun
1b1195288b Add ctrl key support for keyboard handler.
Originally written by @wikenator.
2014-10-14 00:29:51 +01:00
loliver
e6590da884 IE Pointer Events
Added support for PointerEvents (and MSPointerEvents) to support touch
in IE10 and 11.

Modified by @noraesae.
2014-10-14 00:13:04 +01:00
Hyunje Alex Jun
e98bfec4f2 Remove IE6 specific fixes.
Just don't use IE6.
2014-10-13 23:47:47 +01:00
Hyunje Alex Jun
f7d90464e0 More code refactoring.
It's never enough.
2014-10-13 23:47:47 +01:00
Hyunje Alex Jun
337c0be9e2 Add int() helper instead of parseInt.
parseInt is a good option for string-int conversion,
but none for float-int conversion because of performance issue.

This is also to make the code clean.
2014-10-13 23:24:20 +01:00
Hyunje Alex Jun
36c988faba Code refactoring. 2014-10-13 23:24:20 +01:00
Mathieu Lorber
a573d2cd9d ShadowDom form elements are considered for preventing scrolling by keyevent 2014-10-01 11:49:16 +02:00
Hyunje Alex Jun
f231110f21 Merge pull request #217 from josemalonsom/patch-1
Minor corrections in example.
2014-09-29 21:54:11 +01:00
josemalonsom
503b05f5ae Minor corrections in example.
Just a couple of minor corrections in the CSS of the example "How to use".
2014-09-29 22:18:05 +02:00
Hyunje Alex Jun
abab1e47a4 Release 0.5.2.
1. Hide suppressed scrollbar rails.
2014-09-28 01:30:58 +01:00
Hyunje Alex Jun
c1b40168f6 Hide scrollbar rails when they're suppressed.
They were displayed even though suppresed. In this patch,
the scrollbar rails won't be displayed unless they're needed.
2014-09-28 01:28:38 +01:00
Hyunje Alex Jun
937463cf75 Change name. 2014-09-24 19:35:43 +01:00
Hyunje Alex Jun
424e577dbc Bump up version in bower.json 2014-09-16 11:28:40 +01:00
Hyunje Alex Jun
575280e9c2 Release 0.5.1.
1. Change dragging logic.
2. Remove jquery-mousewheel dependency.
3. Bug fixes.
2014-09-15 22:58:28 +01:00
Hyunje Alex Jun
d3181f0b0d Mousewheel fixes for Firefox and IE 10.
Now tested with the latest versions of following browsers.

In OS X:
Chrome
Firefox
Safari

In Windows:
Chrome
Firefox
Internet Explorer 10
Opera
Safari
2014-09-15 22:53:40 +01:00
Hyunje Alex Jun
0fc81dfa83 Remove Firefox hack for MozMousePixelScroll.
It just works fine without it.
2014-09-15 21:53:23 +01:00
Hyunje Alex Jun
1d315786a0 Hide scrollbars while updating to stop affecting geometries.
Scrollbars keep affecting the geometries and it leads to wrong
scrollWidth and scrollHeight. So hide them in advance and show
them again after updating.
2014-09-15 21:45:27 +01:00
Hyunje Alex Jun
32a0caf2d8 Change wheelSpeed of text-content example.
The default value is changed.
2014-09-15 21:40:15 +01:00
Hyunje Alex Jun
22bffa9ba8 Add update functionality to options-default example.
It's useful to test the plugin with the update function.
2014-09-15 14:05:34 +01:00
Hyunje Alex Jun
babd3949c7 Update README.md
Gitter doesn't work well.
2014-08-31 01:35:43 +01:00
Hyunje Alex Jun
cbdccf9736 Remove jquery-mousewheel dependencies.
Tested under OS X.
2014-08-25 00:35:51 +01:00
Hyunje Alex Jun
a63c136c09 Change main property to use non-minified files for bower.
https://github.com/noraesae/perfect-scrollbar/issues/133
2014-08-24 23:30:29 +01:00
SideraX
d272206181 Update package.json to be compatible with browerify.
Updated: non-minified source is preferred for the `main` property.
2014-08-24 23:23:33 +01:00
Hyunje Alex Jun
a022621df8 Change dragging logic.
Using `updateBarSizeAndPosition` instead of manual update of scrollbar
CSS styles.
2014-08-07 13:25:46 +01:00
Hyunje Alex Jun
2b87bbe081 Update README.md
Add Gitter and Travis CI status.
2014-08-06 20:39:16 +01:00
Hyunje Alex Jun
cee1e3f015 Merge pull request #188 from d42f/master
Update perfect-scrollbar.css
2014-08-06 20:27:10 +01:00
d42f
c5f442a70e Update perfect-scrollbar.css
remove spaces
2014-07-29 13:56:38 +04:00
Hyunje Alex Jun
6b35561bb3 Release 0.4.11.
1. Add active- class when scrolls are active
2. Add maxScrollbarLength option
3. Bug fixes
2014-07-16 18:57:45 +01:00
Hyunje Alex Jun
57cc39e6e8 Add 'maxScrollbarLength' option in README.md 2014-07-16 18:56:46 +01:00
Hyunje Alex Jun
3adb98cd40 Merge pull request #174 from ivan1986/patch-1
add maxScrollbarLength.
2014-07-16 18:53:04 +01:00
Martijn Saly
4e90f8c170 Keydown now checks if the event was preventDefault()'ed. 2014-07-16 18:42:40 +01:00
Karol Tomoki Yamazaki
eb13d331d9 Consider border of scrollbar rails.
Fixes #176 https://github.com/noraesae/perfect-scrollbar/issues/176
2014-07-16 18:40:57 +01:00
Hyunje Alex Jun
c6f2e6abd3 Merge pull request #159 from sarunas/master
Add ps-visible class on container then scrollbar is active.
2014-07-16 18:37:21 +01:00
Hyunje Alex Jun
845452f654 Merge pull request #173 from jlcarvalho/patch-1
Update README.md.
2014-07-16 18:35:51 +01:00
Ivan Borzenkov
49a2a694b9 add maxScrollbarLength 2014-07-09 21:16:16 +04:00
jlcarvalho
1f8a37894b Update README.md
The container must have the properties height and overflow.
2014-07-09 11:26:54 -03:00
Šarūnas Dubinskas
fd56fdfe02 Add ps-active-* class on container then scrollbar is active 2014-07-07 10:42:37 +03:00
Hyunje Alex Jun
6fa5f198e2 Add help text for wheelPropagation option. 2014-07-05 18:01:24 +01:00
Hyunje Alex Jun
f8759f713c Unify jQuery version dependencies. 2014-07-05 17:46:17 +01:00
Hyunje Alex Jun
4b3b057838 Merge pull request #152 from slopjong/hotfix/version-removed-from-dist-files
Removed version from dist file names. Fixes #150.
2014-05-17 10:55:42 +01:00
slopjong
b5675c4d5b Removed version from dist file names 2014-05-17 06:55:21 +02:00
Hyunje Alex Jun
6e2d95f309 Change emails in json files. 2014-04-29 14:22:02 +01:00
26 changed files with 504 additions and 595 deletions

View File

@@ -27,7 +27,7 @@
"asi" : false,
"laxbreak" : false,
"bitwise" : true,
"bitwise" : false,
"boss" : false,
"curly" : true,
"eqeqeq" : true,

View File

@@ -6,8 +6,7 @@ module.exports = function (grunt) {
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('perfect-scrollbar.jquery.json'),
version: grunt.file.readJSON('package.json').version,
banner: '/*! <%= pkg.title || pkg.name %> - v<%= version %>\n' +
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
@@ -21,11 +20,7 @@ module.exports = function (grunt) {
},
min: {
files: {
'min/perfect-scrollbar-<%= version %>.min.js': ['src/perfect-scrollbar.js'],
'min/perfect-scrollbar-<%= version %>.with-mousewheel.min.js': [
'src/perfect-scrollbar.js',
'src/jquery.mousewheel.js'
]
'min/perfect-scrollbar.min.js': ['src/perfect-scrollbar.js']
}
}
},
@@ -61,7 +56,16 @@ module.exports = function (grunt) {
cwd: 'src/',
src: ['perfect-scrollbar.css'],
dest: 'min/',
ext: '-<%= version %>.min.css'
ext: '.min.css'
}
},
bump: {
options: {
files: ['package.json', 'bower.json', 'perfect-scrollbar.jquery.json'],
updateConfigs: ['pkg'],
commit: false,
createTag: false,
push: false
}
}
});
@@ -72,6 +76,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-bump');
grunt.registerTask('default', 'List commands', function () {
grunt.log.writeln("");
@@ -83,5 +88,9 @@ module.exports = function (grunt) {
grunt.registerTask('lint', ['jshint', 'csslint']);
grunt.registerTask('build', ['clean', 'uglify', 'cssmin']);
grunt.registerTask('travis', ['lint']);
grunt.registerTask('release', 'Release a new version', function (arg) {
var bumpType = arg ? ':' + arg : '';
grunt.task.run(['lint', 'bump' + bumpType, 'build']);
});
};

View File

@@ -1,4 +1,4 @@
perfect-scrollbar
perfect-scrollbar [![Travis CI](https://travis-ci.org/noraesae/perfect-scrollbar.svg?branch=master)](https://travis-ci.org/noraesae/perfect-scrollbar)
=================
Tiny but perfect jQuery scrollbar plugin
@@ -44,16 +44,24 @@ You can download the latest stable version with download links in [Github 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
$ git clone https://github.com/noraesae/perfect-scrollbar.git
$ cd perfect-scrollbar/src
```
You can use [Bower](http://bower.io/) to install the plugin. The plugin is registered as `perfect-scrollbar`.
```
bower install perfect-scrollbar
$ bower install perfect-scrollbar
```
It's registered on [npm](https://www.npmjs.org/package/perfect-scrollbar) as `perfect-scrollbar`.
```
$ npm install perfect-scrollbar
```
You can also load it from [cdnjs](http://cdnjs.com/). It is registered as [`jquery.perfect-scrollbar`](http://www.cdnjs.com/libraries/jquery.perfect-scrollbar).
Requirements
------------
@@ -67,7 +75,7 @@ To make this plugin *perfect*, some requirements were not avoidable. But they're
The requirement below is for perfect-scrollbar &lt;= 0.3.4
* there must be the *one* content element(like div) for the container.
Optional parameters
-------------------
@@ -75,16 +83,22 @@ perfect-scrollbar supports optional parameters.
### wheelSpeed
The scroll speed applied to mousewheel event.
**Default: 10**
**Default: 1**
### 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**
@@ -118,7 +132,11 @@ How to Use
```html
<style>
#Demo { position: 'relative'; }
#Demo {
position: relative;
height: 100%; /* Or whatever you want (eg. 400px) */
overflow: hidden;
}
</style>
<div id='Demo'>
<div>
@@ -157,13 +175,6 @@ $("#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](https://github.com/brandonaaron/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](https://github.com/cowboy/jquery-resize) can be helpful.
Contribution
------------
@@ -181,11 +192,9 @@ For IE problems, please refer to [IE Support](https://github.com/noraesae/perfec
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).
The plugin would work in IEs >= IE9(not well, though).
**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.
**The patches to fix problems in IE<=8 won't be accepted.**
When old IEs should be supported, please fork the project and make patches personally.
@@ -197,7 +206,7 @@ If you have any idea to improve this project or any problem using this, please f
License
-------
The MIT License (MIT) Copyright (c) 2012, 2014 Hyeonje Alex Jun and other contributors.
The MIT License (MIT) Copyright (c) 2012, 2014 Hyunje 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:

View File

@@ -1,15 +1,14 @@
{
"name": "perfect-scrollbar",
"version": "0.4.10",
"version": "0.5.5",
"homepage": "http://noraesae.github.io/perfect-scrollbar/",
"authors": [
"Hyeonje Alex Jun <noraesae@yuiazu.net>"
"Hyunje Alex Jun <me@noraesae.net>"
],
"description": "Tiny but perfect jQuery scrollbar plugin",
"main": [
"min/perfect-scrollbar-0.4.10.min.css",
"min/perfect-scrollbar-0.4.10.min.js",
"min/perfect-scrollbar-0.4.10.with-mousewheel.min.js"
"src/perfect-scrollbar.css",
"src/perfect-scrollbar.js"
],
"license": "MIT",
"ignore": [
@@ -20,6 +19,6 @@
"tests"
],
"dependencies": {
"jquery": "2.x"
"jquery": ">=1.10"
}
}

View File

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<style>
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 600px; height: 400px; overflow: hidden; }
.contentHolder .content { background-image: url('./azusa.jpg'); width: 1280px; height: 720px; }
.spacer { text-align:center }
</style>
</head>
<body>
<div id="Default" class="contentHolder">
<div class="content">
</div>
</div>
</body>
</html>

27
examples/iframe.html Normal file
View File

@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
#iframe { width: 100%; min-height: 450px; border: 0; }
html { direction: rtl; }
</style>
<script>
jQuery(document).ready(function ($) {
"use strict";
$('#iframe').load(function() {
var contentIframe = $(this).contents();
var documentIframe = contentIframe.get(0);
$('#Default', documentIframe).perfectScrollbar();
});
});
</script>
</head>
<body>
<iframe src="iframe-content.html" id="iframe"></iframe>
</body>
</html>

View File

@@ -5,7 +5,6 @@
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/jquery.mousewheel.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 600px; height: 400px; overflow: hidden; }
@@ -17,6 +16,11 @@
"use strict";
$('#Default').perfectScrollbar();
});
var updateSize = function () {
var width = parseInt($('#width').val(), 10);
var height = parseInt($('#height').val(), 10);
$('#Default').width(width).height(height).perfectScrollbar('update');
};
</script>
</head>
<body>
@@ -24,6 +28,11 @@
<div class="content">
</div>
</div>
<p style='text-align: center'>
Width <input type='text' id='width' value='600'>
Height <input type='text' id='height' value='400'>
<button onclick='updateSize()'>Change!</button>
</p>
</body>
</html>

View File

@@ -5,7 +5,6 @@
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/jquery.mousewheel.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 640px; height: 360px; overflow: hidden; }

View File

@@ -5,7 +5,6 @@
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/jquery.mousewheel.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 600px; height: 400px; overflow: hidden; }

View File

@@ -5,7 +5,6 @@
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/jquery.mousewheel.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 640px; height: 360px; overflow: hidden; }

View File

@@ -5,7 +5,6 @@
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/jquery.mousewheel.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 600px; height: 400px; overflow: hidden; }

View File

@@ -5,7 +5,6 @@
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/jquery.mousewheel.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 600px; height: 400px; overflow: hidden; }
@@ -16,23 +15,23 @@
jQuery(document).ready(function ($) {
"use strict";
$('#Default').perfectScrollbar();
$('#FastWheelSpeed').perfectScrollbar({wheelSpeed:100});
$('#SlowWheelSpeed').perfectScrollbar({wheelSpeed:1});
$('#FastWheelSpeed').perfectScrollbar({wheelSpeed:10});
$('#SlowWheelSpeed').perfectScrollbar({wheelSpeed:0.1});
});
</script>
</head>
<body>
<h1 style="text-align:center">Default; wheelSpeed:10</h1>
<h1 style="text-align:center">Default; wheelSpeed:1</h1>
<div id="Default" class="contentHolder">
<div class="content">
</div>
</div>
<h1 style="text-align:center">Fast: wheelSpeed:100</h1>
<h1 style="text-align:center">Fast: wheelSpeed:10</h1>
<div id="FastWheelSpeed" class="contentHolder">
<div class="content">
</div>
</div>
<h1 style="text-align:center">Slow: wheelSpeed:1</h1>
<h1 style="text-align:center">Slow: wheelSpeed:0.1</h1>
<div id="SlowWheelSpeed" class="contentHolder">
<div class="content">
</div>

View File

@@ -6,7 +6,6 @@
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/jquery.mousewheel.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
#description {

View File

@@ -5,7 +5,6 @@
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/jquery.mousewheel.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 600px; height: 400px; overflow: hidden; }

View File

@@ -5,7 +5,6 @@
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/jquery.mousewheel.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 600px; height: 400px; overflow: hidden; }

View File

@@ -6,7 +6,6 @@
<title>perfect-scrollbar example</title>
<link href="../src/perfect-scrollbar.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../src/jquery.mousewheel.js"></script>
<script src="../src/perfect-scrollbar.js"></script>
<style>
#description {
@@ -19,10 +18,7 @@
</style>
<script type="text/javascript">
$(document).ready(function ($) {
$('#description').perfectScrollbar({
wheelSpeed: 20,
wheelPropagation: false
});
$('#description').perfectScrollbar();
});
</script>
</head>

View File

@@ -1,5 +0,0 @@
/*! perfect-scrollbar - v0.4.10
* http://noraesae.github.com/perfect-scrollbar/
* Copyright (c) 2014 Hyeonje Alex Jun; Licensed MIT */
.ps-container .ps-scrollbar-x-rail{position:absolute;bottom:3px;height:8px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0;filter:alpha(opacity=0);-o-transition:background-color .2s linear,opacity .2s linear;-webkit-transition:background-color .2s linear,opacity .2s linear;-moz-transition:background-color .2s linear,opacity .2s linear;transition:background-color .2s linear,opacity .2s linear}.ps-container:hover .ps-scrollbar-x-rail,.ps-container.hover .ps-scrollbar-x-rail{opacity:.6;filter:alpha(opacity=60)}.ps-container .ps-scrollbar-x-rail:hover,.ps-container .ps-scrollbar-x-rail.hover{background-color:#eee;opacity:.9;filter:alpha(opacity=90)}.ps-container .ps-scrollbar-x-rail.in-scrolling{background-color:#eee;opacity:.9;filter:alpha(opacity=90)}.ps-container .ps-scrollbar-y-rail{position:absolute;right:3px;width:8px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0;filter:alpha(opacity=0);-o-transition:background-color .2s linear,opacity .2s linear;-webkit-transition:background-color .2s linear,opacity .2s linear;-moz-transition:background-color .2s linear,opacity .2s linear;transition:background-color .2s linear,opacity .2s linear}.ps-container:hover .ps-scrollbar-y-rail,.ps-container.hover .ps-scrollbar-y-rail{opacity:.6;filter:alpha(opacity=60)}.ps-container .ps-scrollbar-y-rail:hover,.ps-container .ps-scrollbar-y-rail.hover{background-color:#eee;opacity:.9;filter:alpha(opacity=90)}.ps-container .ps-scrollbar-y-rail.in-scrolling{background-color:#eee;opacity:.9;filter:alpha(opacity=90)}.ps-container .ps-scrollbar-x{position:absolute;bottom:0;height:8px;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-o-transition:background-color .2s linear;-webkit-transition:background-color.2s linear;-moz-transition:background-color .2s linear;transition:background-color .2s linear}.ps-container.ie6 .ps-scrollbar-x{font-size:0}.ps-container .ps-scrollbar-x-rail:hover .ps-scrollbar-x,.ps-container .ps-scrollbar-x-rail.hover .ps-scrollbar-x{background-color:#999}.ps-container .ps-scrollbar-y{position:absolute;right:0;width:8px;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-o-transition:background-color .2s linear;-webkit-transition:background-color.2s linear;-moz-transition:background-color .2s linear;transition:background-color .2s linear}.ps-container.ie6 .ps-scrollbar-y{font-size:0}.ps-container .ps-scrollbar-y-rail:hover .ps-scrollbar-y,.ps-container .ps-scrollbar-y-rail.hover .ps-scrollbar-y{background-color:#999}.ps-container.ie .ps-scrollbar-x,.ps-container.ie .ps-scrollbar-y{visibility:hidden}.ps-container.ie:hover .ps-scrollbar-x,.ps-container.ie:hover .ps-scrollbar-y,.ps-container.ie.hover .ps-scrollbar-x,.ps-container.ie.hover .ps-scrollbar-y{visibility:visible}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

5
min/perfect-scrollbar.min.css vendored Normal file
View File

@@ -0,0 +1,5 @@
/*! perfect-scrollbar - v0.5.5
* http://noraesae.github.com/perfect-scrollbar/
* Copyright (c) 2014 Hyunje Alex Jun; Licensed MIT */
.ps-container>.ps-scrollbar-x-rail{position:absolute;bottom:3px;height:8px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0;filter:alpha(opacity=0);-o-transition:background-color .2s linear,opacity .2s linear;-webkit-transition:background-color .2s linear,opacity .2s linear;-moz-transition:background-color .2s linear,opacity .2s linear;transition:background-color .2s linear,opacity .2s linear}.ps-container:hover>.ps-scrollbar-x-rail{opacity:.6;filter:alpha(opacity=60)}.ps-container>.ps-scrollbar-x-rail:hover{background-color:#eee;opacity:.9;filter:alpha(opacity=90)}.ps-container>.ps-scrollbar-x-rail.in-scrolling{background-color:#eee;opacity:.9;filter:alpha(opacity=90)}.ps-container>.ps-scrollbar-y-rail{position:absolute;right:3px;width:8px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0;filter:alpha(opacity=0);-o-transition:background-color .2s linear,opacity .2s linear;-webkit-transition:background-color .2s linear,opacity .2s linear;-moz-transition:background-color .2s linear,opacity .2s linear;transition:background-color .2s linear,opacity .2s linear}.ps-container:hover>.ps-scrollbar-y-rail{opacity:.6;filter:alpha(opacity=60)}.ps-container>.ps-scrollbar-y-rail:hover{background-color:#eee;opacity:.9;filter:alpha(opacity=90)}.ps-container>.ps-scrollbar-y-rail.in-scrolling{background-color:#eee;opacity:.9;filter:alpha(opacity=90)}.ps-container>.ps-scrollbar-x-rail>.ps-scrollbar-x{position:absolute;bottom:0;height:8px;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-o-transition:background-color .2s linear;-webkit-transition:background-color.2s linear;-moz-transition:background-color .2s linear;transition:background-color .2s linear}.ps-container>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x{background-color:#999}.ps-container>.ps-scrollbar-y-rail>.ps-scrollbar-y{position:absolute;right:0;width:8px;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-o-transition:background-color .2s linear;-webkit-transition:background-color.2s linear;-moz-transition:background-color .2s linear;transition:background-color .2s linear}.ps-container>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y{background-color:#999}

4
min/perfect-scrollbar.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,18 +1,39 @@
{
"name": "perfect-scrollbar",
"version": "0.4.10",
"version": "0.5.5",
"description": "Tiny but perfect jquery scrollbar plugin.",
"author": "Hyunje Alex Jun <me@noraesae.net>",
"contributors": [{
"name": "Hyunje Alex Jun",
"email": "me@noraesae.net"
}],
"main": "src/perfect-scrollbar.js",
"repository": {
"type": "git",
"url": "https://github.com/noraesae/perfect-scrollbar"
},
"bugs": {
"url": "https://github.com/noraesae/perfect-scrollbar/issues"
},
"keywords": [
"jquery-plugin",
"scroll",
"scrollbar"
],
"engines": {
"node": ">= 0.8.0"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-uglify": "~0.1.1",
"grunt-contrib-cssmin": "~0.6.1",
"grunt-bump": "0.0.16",
"grunt-contrib-clean": "~0.4.1",
"grunt-contrib-csslint": "~0.1.2",
"grunt-contrib-clean": "~0.4.1"
"grunt-contrib-cssmin": "~0.6.1",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-uglify": "~0.1.1"
},
"scripts": {
"test": "grunt travis --verbose"
}
},
"license": "MIT"
}

View File

@@ -2,10 +2,10 @@
"name": "perfect-scrollbar",
"title": "perfect-scrollbar",
"description": "Tiny but perfect jquery scrollbar plugin.",
"version": "0.4.10",
"version": "0.5.5",
"author": {
"name": "Hyeonje Alex Jun",
"email": "noraesae@yuiazu.net",
"name": "Hyunje Alex Jun",
"email": "me@noraesae.net",
"url": "https://github.com/noraesae/"
},
"licenses": [
@@ -15,7 +15,7 @@
}
],
"dependencies": {
"jquery": ">=1.8"
"jquery": ">=1.10"
},
"keywords": [
"ui",
@@ -29,8 +29,8 @@
"bugs": "https://github.com/noraesae/perfect-scrollbar/issues/",
"maintainers": [
{
"name": "Hyeonje Alex Jun",
"email": "noraesae@yuiazu.net",
"name": "Hyunje Alex Jun",
"email": "me@noraesae.net",
"url": "https://github.com/noraesae/"
}
]

View File

@@ -1,201 +0,0 @@
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
* Licensed under the MIT License (LICENSE.txt).
*
* Version: 3.1.9
*
* Requires: jQuery 1.2.2+
*/
(function (factory) {
if ( typeof define === 'function' && define.amd ) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS style for Browserify
module.exports = factory;
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
slice = Array.prototype.slice,
nullLowestDeltaTimeout, lowestDelta;
if ( $.event.fixHooks ) {
for ( var i = toFix.length; i; ) {
$.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
}
}
var special = $.event.special.mousewheel = {
version: '3.1.9',
setup: function() {
if ( this.addEventListener ) {
for ( var i = toBind.length; i; ) {
this.addEventListener( toBind[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
// Store the line height and page height for this particular element
$.data(this, 'mousewheel-line-height', special.getLineHeight(this));
$.data(this, 'mousewheel-page-height', special.getPageHeight(this));
},
teardown: function() {
if ( this.removeEventListener ) {
for ( var i = toBind.length; i; ) {
this.removeEventListener( toBind[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
},
getLineHeight: function(elem) {
return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10);
},
getPageHeight: function(elem) {
return $(elem).height();
},
settings: {
adjustOldDeltas: true
}
};
$.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
},
unmousewheel: function(fn) {
return this.unbind('mousewheel', fn);
}
});
function handler(event) {
var orgEvent = event || window.event,
args = slice.call(arguments, 1),
delta = 0,
deltaX = 0,
deltaY = 0,
absDelta = 0;
event = $.event.fix(orgEvent);
event.type = 'mousewheel';
// Old school scrollwheel delta
if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaX = deltaY * -1;
deltaY = 0;
}
// Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
delta = deltaY === 0 ? deltaX : deltaY;
// New school wheel delta (wheel event)
if ( 'deltaY' in orgEvent ) {
deltaY = orgEvent.deltaY * -1;
delta = deltaY;
}
if ( 'deltaX' in orgEvent ) {
deltaX = orgEvent.deltaX;
if ( deltaY === 0 ) { delta = deltaX * -1; }
}
// No change actually happened, no reason to go any further
if ( deltaY === 0 && deltaX === 0 ) { return; }
// Need to convert lines and pages to pixels if we aren't already in pixels
// There are three delta modes:
// * deltaMode 0 is by pixels, nothing to do
// * deltaMode 1 is by lines
// * deltaMode 2 is by pages
if ( orgEvent.deltaMode === 1 ) {
var lineHeight = $.data(this, 'mousewheel-line-height');
delta *= lineHeight;
deltaY *= lineHeight;
deltaX *= lineHeight;
} else if ( orgEvent.deltaMode === 2 ) {
var pageHeight = $.data(this, 'mousewheel-page-height');
delta *= pageHeight;
deltaY *= pageHeight;
deltaX *= pageHeight;
}
// Store lowest absolute delta to normalize the delta values
absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
if ( !lowestDelta || absDelta < lowestDelta ) {
lowestDelta = absDelta;
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
lowestDelta /= 40;
}
}
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
// Divide all the things by 40!
delta /= 40;
deltaX /= 40;
deltaY /= 40;
}
// Get a whole, normalized value for the deltas
delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
// Add information to the event object
event.deltaX = deltaX;
event.deltaY = deltaY;
event.deltaFactor = lowestDelta;
// Go ahead and set deltaMode to 0 since we converted to pixels
// Although this is a little odd since we overwrite the deltaX/Y
// properties with normalized deltas.
event.deltaMode = 0;
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
// Clearout lowestDelta after sometime to better
// handle multiple device types that give different
// a different lowestDelta
// Ex: trackpad = 3 and mouse wheel = 120
if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
return ($.event.dispatch || $.event.handle).apply(this, args);
}
function nullLowestDelta() {
lowestDelta = null;
}
function shouldAdjustOldDeltas(orgEvent, absDelta) {
// If this is an older event and the delta is divisable by 120,
// then we are assuming that the browser is treating this as an
// older mouse wheel event and that we should divide the deltas
// by 40 to try and get a more usable deltaFactor.
// Side note, this actually impacts the reported scroll distance
// in older browsers and can cause scrolling to be slower than native.
// Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
}
}));

View File

@@ -1,4 +1,4 @@
.ps-container .ps-scrollbar-x-rail {
.ps-container>.ps-scrollbar-x-rail {
position: absolute; /* please don't change 'position' */
bottom: 3px; /* there must be 'bottom' for ps-scrollbar-x-rail */
height: 8px;
@@ -6,33 +6,31 @@
-moz-border-radius: 4px;
border-radius: 4px;
opacity: 0;
filter: alpha(opacity = 0);
filter: alpha(opacity=0);
-o-transition: background-color .2s linear, opacity .2s linear;
-webkit-transition: background-color .2s linear, opacity .2s linear;
-moz-transition: background-color .2s linear, opacity .2s linear;
transition: background-color .2s linear, opacity .2s linear;
}
.ps-container:hover .ps-scrollbar-x-rail,
.ps-container.hover .ps-scrollbar-x-rail {
.ps-container:hover>.ps-scrollbar-x-rail {
opacity: 0.6;
filter: alpha(opacity = 60);
filter: alpha(opacity=60);
}
.ps-container .ps-scrollbar-x-rail:hover,
.ps-container .ps-scrollbar-x-rail.hover {
.ps-container>.ps-scrollbar-x-rail:hover {
background-color: #eee;
opacity: 0.9;
filter: alpha(opacity = 90);
filter: alpha(opacity=90);
}
.ps-container .ps-scrollbar-x-rail.in-scrolling {
.ps-container>.ps-scrollbar-x-rail.in-scrolling {
background-color: #eee;
opacity: 0.9;
filter: alpha(opacity = 90);
filter: alpha(opacity=90);
}
.ps-container .ps-scrollbar-y-rail {
.ps-container>.ps-scrollbar-y-rail {
position: absolute; /* please don't change 'position' */
right: 3px; /* there must be 'right' for ps-scrollbar-y-rail */
width: 8px;
@@ -47,26 +45,24 @@
transition: background-color .2s linear, opacity .2s linear;
}
.ps-container:hover .ps-scrollbar-y-rail,
.ps-container.hover .ps-scrollbar-y-rail {
.ps-container:hover>.ps-scrollbar-y-rail {
opacity: 0.6;
filter: alpha(opacity = 60);
filter: alpha(opacity=60);
}
.ps-container .ps-scrollbar-y-rail:hover,
.ps-container .ps-scrollbar-y-rail.hover {
.ps-container>.ps-scrollbar-y-rail:hover {
background-color: #eee;
opacity: 0.9;
filter: alpha(opacity = 90);
filter: alpha(opacity=90);
}
.ps-container .ps-scrollbar-y-rail.in-scrolling {
.ps-container>.ps-scrollbar-y-rail.in-scrolling {
background-color: #eee;
opacity: 0.9;
filter: alpha(opacity = 90);
filter: alpha(opacity=90);
}
.ps-container .ps-scrollbar-x {
.ps-container>.ps-scrollbar-x-rail>.ps-scrollbar-x {
position: absolute; /* please don't change 'position' */
bottom: 0; /* there must be 'bottom' for ps-scrollbar-x */
height: 8px;
@@ -80,16 +76,11 @@
transition: background-color .2s linear;
}
.ps-container.ie6 .ps-scrollbar-x {
font-size: 0; /* fixed scrollbar height in xp sp3 ie6 */
}
.ps-container .ps-scrollbar-x-rail:hover .ps-scrollbar-x,
.ps-container .ps-scrollbar-x-rail.hover .ps-scrollbar-x {
.ps-container>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x {
background-color: #999;
}
.ps-container .ps-scrollbar-y {
.ps-container>.ps-scrollbar-y-rail>.ps-scrollbar-y {
position: absolute; /* please don't change 'position' */
right: 0; /* there must be 'right' for ps-scrollbar-y */
width: 8px;
@@ -103,23 +94,6 @@
transition: background-color .2s linear;
}
.ps-container.ie6 .ps-scrollbar-y {
font-size: 0; /* fixed scrollbar height in xp sp3 ie6 */
}
.ps-container .ps-scrollbar-y-rail:hover .ps-scrollbar-y,
.ps-container .ps-scrollbar-y-rail.hover .ps-scrollbar-y {
.ps-container>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y {
background-color: #999;
}
.ps-container.ie .ps-scrollbar-x,
.ps-container.ie .ps-scrollbar-y {
visibility: hidden;
}
.ps-container.ie:hover .ps-scrollbar-x,
.ps-container.ie:hover .ps-scrollbar-y,
.ps-container.ie.hover .ps-scrollbar-x,
.ps-container.ie.hover .ps-scrollbar-y {
visibility: visible;
}

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2012, 2014 Hyeonje Alex Jun and other contributors
/* Copyright (c) 2012, 2014 Hyunje Alex Jun and other contributors
* Licensed under the MIT License
*/
(function (factory) {
@@ -14,14 +14,22 @@
// Browser globals
factory(jQuery);
}
}(function ($) {
})(function ($) {
'use strict';
// The default settings for the plugin
function int(x) {
if (typeof x === 'string') {
return parseInt(x, 10);
} else {
return ~~x;
}
}
var defaultSettings = {
wheelSpeed: 10,
wheelSpeed: 1,
wheelPropagation: false,
minScrollbarLength: null,
maxScrollbarLength: null,
useBothWheelAxes: false,
useKeyboard: true,
suppressScrollX: false,
@@ -38,25 +46,23 @@
incrementingId += 1;
return '.perfect-scrollbar-' + id;
};
}());
})();
$.fn.perfectScrollbar = function (suppliedSettings, option) {
return this.each(function () {
// Use the default settings
var settings = $.extend(true, {}, defaultSettings),
$this = $(this);
var settings = $.extend(true, {}, defaultSettings);
var $this = $(this);
if (typeof suppliedSettings === "object") {
// But over-ride any supplied
// Override default settings with any supplied
$.extend(true, settings, suppliedSettings);
} else {
// If no settings were supplied, then the first param must be the option
// If no setting was supplied, then the first param must be the option
option = suppliedSettings;
}
// Catch options
if (option === 'update') {
if ($this.data('perfect-scrollbar-update')) {
$this.data('perfect-scrollbar-update')();
@@ -78,123 +84,119 @@
// Or generate new perfectScrollbar
// Set class to the container
$this.addClass('ps-container');
var $scrollbarXRail = $("<div class='ps-scrollbar-x-rail'></div>").appendTo($this),
$scrollbarYRail = $("<div class='ps-scrollbar-y-rail'></div>").appendTo($this),
$scrollbarX = $("<div class='ps-scrollbar-x'></div>").appendTo($scrollbarXRail),
$scrollbarY = $("<div class='ps-scrollbar-y'></div>").appendTo($scrollbarYRail),
scrollbarXActive,
scrollbarYActive,
containerWidth,
containerHeight,
contentWidth,
contentHeight,
scrollbarXWidth,
scrollbarXLeft,
scrollbarXBottom = parseInt($scrollbarXRail.css('bottom'), 10),
isScrollbarXUsingBottom = scrollbarXBottom === scrollbarXBottom, // !isNaN
scrollbarXTop = isScrollbarXUsingBottom ? null : parseInt($scrollbarXRail.css('top'), 10),
scrollbarYHeight,
scrollbarYTop,
scrollbarYRight = parseInt($scrollbarYRail.css('right'), 10),
isScrollbarYUsingRight = scrollbarYRight === scrollbarYRight, // !isNaN
scrollbarYLeft = isScrollbarYUsingRight ? null: parseInt($scrollbarYRail.css('left'), 10),
isRtl = $this.css('direction') === "rtl",
eventClassName = getEventClassName();
var containerWidth;
var containerHeight;
var contentWidth;
var contentHeight;
var updateContentScrollTop = function (currentTop, deltaY) {
var newTop = currentTop + deltaY,
maxTop = containerHeight - scrollbarYHeight;
var isRtl = $this.css('direction') === "rtl";
var eventClassName = getEventClassName();
var ownerDocument = this.ownerDocument || document;
var $scrollbarXRail = $("<div class='ps-scrollbar-x-rail'>").appendTo($this);
var $scrollbarX = $("<div class='ps-scrollbar-x'>").appendTo($scrollbarXRail);
var scrollbarXActive;
var scrollbarXWidth;
var scrollbarXLeft;
var scrollbarXBottom = int($scrollbarXRail.css('bottom'));
var isScrollbarXUsingBottom = scrollbarXBottom === scrollbarXBottom; // !isNaN
var scrollbarXTop = isScrollbarXUsingBottom ? null : int($scrollbarXRail.css('top'));
var railBorderXWidth = int($scrollbarXRail.css('borderLeftWidth')) + int($scrollbarXRail.css('borderRightWidth'));
var $scrollbarYRail = $("<div class='ps-scrollbar-y-rail'>").appendTo($this);
var $scrollbarY = $("<div class='ps-scrollbar-y'>").appendTo($scrollbarYRail);
var scrollbarYActive;
var scrollbarYHeight;
var scrollbarYTop;
var scrollbarYRight = int($scrollbarYRail.css('right'));
var isScrollbarYUsingRight = scrollbarYRight === scrollbarYRight; // !isNaN
var scrollbarYLeft = isScrollbarYUsingRight ? null : int($scrollbarYRail.css('left'));
var railBorderYWidth = int($scrollbarYRail.css('borderTopWidth')) + int($scrollbarYRail.css('borderBottomWidth'));
function updateScrollTop(currentTop, deltaY) {
var newTop = currentTop + deltaY;
var maxTop = containerHeight - scrollbarYHeight;
if (newTop < 0) {
scrollbarYTop = 0;
}
else if (newTop > maxTop) {
} else if (newTop > maxTop) {
scrollbarYTop = maxTop;
}
else {
} else {
scrollbarYTop = newTop;
}
var scrollTop = parseInt(scrollbarYTop * (contentHeight - containerHeight) / (containerHeight - scrollbarYHeight), 10);
var scrollTop = int(scrollbarYTop * (contentHeight - containerHeight) / (containerHeight - scrollbarYHeight));
$this.scrollTop(scrollTop);
}
if (isScrollbarXUsingBottom) {
$scrollbarXRail.css({bottom: scrollbarXBottom - scrollTop});
} else {
$scrollbarXRail.css({top: scrollbarXTop + scrollTop});
}
};
var updateContentScrollLeft = function (currentLeft, deltaX) {
var newLeft = currentLeft + deltaX,
maxLeft = containerWidth - scrollbarXWidth;
function updateScrollLeft(currentLeft, deltaX) {
var newLeft = currentLeft + deltaX;
var maxLeft = containerWidth - scrollbarXWidth;
if (newLeft < 0) {
scrollbarXLeft = 0;
}
else if (newLeft > maxLeft) {
} else if (newLeft > maxLeft) {
scrollbarXLeft = maxLeft;
}
else {
} else {
scrollbarXLeft = newLeft;
}
var scrollLeft = parseInt(scrollbarXLeft * (contentWidth - containerWidth) / (containerWidth - scrollbarXWidth), 10);
var scrollLeft = int(scrollbarXLeft * (contentWidth - containerWidth) / (containerWidth - scrollbarXWidth));
$this.scrollLeft(scrollLeft);
}
if (isScrollbarYUsingRight) {
$scrollbarYRail.css({right: scrollbarYRight - scrollLeft});
} else {
$scrollbarYRail.css({left: scrollbarYLeft + scrollLeft});
}
};
var getSettingsAdjustedThumbSize = function (thumbSize) {
function getThumbSize(thumbSize) {
if (settings.minScrollbarLength) {
thumbSize = Math.max(thumbSize, settings.minScrollbarLength);
}
if (settings.maxScrollbarLength) {
thumbSize = Math.min(thumbSize, settings.maxScrollbarLength);
}
return thumbSize;
};
}
var updateScrollbarCss = function () {
var scrollbarXStyles = {width: containerWidth, display: scrollbarXActive ? "inherit": "none"};
function updateCss() {
var xRailOffset = {width: containerWidth, display: scrollbarXActive ? "inherit" : "none"};
if (isRtl) {
scrollbarXStyles.left = $this.scrollLeft() + containerWidth - contentWidth;
xRailOffset.left = $this.scrollLeft() + containerWidth - contentWidth;
} else {
scrollbarXStyles.left = $this.scrollLeft();
xRailOffset.left = $this.scrollLeft();
}
if (isScrollbarXUsingBottom) {
scrollbarXStyles.bottom = scrollbarXBottom - $this.scrollTop();
xRailOffset.bottom = scrollbarXBottom - $this.scrollTop();
} else {
scrollbarXStyles.top = scrollbarXTop + $this.scrollTop();
xRailOffset.top = scrollbarXTop + $this.scrollTop();
}
$scrollbarXRail.css(scrollbarXStyles);
$scrollbarXRail.css(xRailOffset);
var scrollbarYStyles = {top: $this.scrollTop(), height: containerHeight, display: scrollbarYActive ? "inherit": "none"};
var railYOffset = {top: $this.scrollTop(), height: containerHeight, display: scrollbarYActive ? "inherit" : "none"};
if (isScrollbarYUsingRight) {
if (isRtl) {
scrollbarYStyles.right = contentWidth - $this.scrollLeft() - scrollbarYRight - $scrollbarY.outerWidth();
railYOffset.right = contentWidth - $this.scrollLeft() - scrollbarYRight - $scrollbarY.outerWidth();
} else {
scrollbarYStyles.right = scrollbarYRight - $this.scrollLeft();
railYOffset.right = scrollbarYRight - $this.scrollLeft();
}
} else {
if (isRtl) {
scrollbarYStyles.left = $this.scrollLeft() + containerWidth * 2 - contentWidth - scrollbarYLeft - $scrollbarY.outerWidth();
railYOffset.left = $this.scrollLeft() + containerWidth * 2 - contentWidth - scrollbarYLeft - $scrollbarY.outerWidth();
} else {
scrollbarYStyles.left = scrollbarYLeft + $this.scrollLeft();
railYOffset.left = scrollbarYLeft + $this.scrollLeft();
}
}
$scrollbarYRail.css(scrollbarYStyles);
$scrollbarYRail.css(railYOffset);
$scrollbarX.css({left: scrollbarXLeft, width: scrollbarXWidth});
$scrollbarY.css({top: scrollbarYTop, height: scrollbarYHeight});
};
$scrollbarX.css({left: scrollbarXLeft, width: scrollbarXWidth - railBorderXWidth});
$scrollbarY.css({top: scrollbarYTop, height: scrollbarYHeight - railBorderYWidth});
}
function updateGeometry() {
// Hide scrollbars not to affect scrollWidth and scrollHeight
$scrollbarXRail.hide();
$scrollbarYRail.hide();
var updateBarSizeAndPosition = function () {
containerWidth = settings.includePadding ? $this.innerWidth() : $this.width();
containerHeight = settings.includePadding ? $this.innerHeight() : $this.height();
contentWidth = $this.prop('scrollWidth');
@@ -202,10 +204,9 @@
if (!settings.suppressScrollX && containerWidth + settings.scrollXMarginOffset < contentWidth) {
scrollbarXActive = true;
scrollbarXWidth = getSettingsAdjustedThumbSize(parseInt(containerWidth * containerWidth / contentWidth, 10));
scrollbarXLeft = parseInt($this.scrollLeft() * (containerWidth - scrollbarXWidth) / (contentWidth - containerWidth), 10);
}
else {
scrollbarXWidth = getThumbSize(int(containerWidth * containerWidth / contentWidth));
scrollbarXLeft = int($this.scrollLeft() * (containerWidth - scrollbarXWidth) / (contentWidth - containerWidth));
} else {
scrollbarXActive = false;
scrollbarXWidth = 0;
scrollbarXLeft = 0;
@@ -214,29 +215,48 @@
if (!settings.suppressScrollY && containerHeight + settings.scrollYMarginOffset < contentHeight) {
scrollbarYActive = true;
scrollbarYHeight = getSettingsAdjustedThumbSize(parseInt(containerHeight * containerHeight / contentHeight, 10));
scrollbarYTop = parseInt($this.scrollTop() * (containerHeight - scrollbarYHeight) / (contentHeight - containerHeight), 10);
}
else {
scrollbarYHeight = getThumbSize(int(containerHeight * containerHeight / contentHeight));
scrollbarYTop = int($this.scrollTop() * (containerHeight - scrollbarYHeight) / (contentHeight - containerHeight));
} else {
scrollbarYActive = false;
scrollbarYHeight = 0;
scrollbarYTop = 0;
$this.scrollTop(0);
}
if (scrollbarYTop >= containerHeight - scrollbarYHeight) {
scrollbarYTop = containerHeight - scrollbarYHeight;
}
if (scrollbarXLeft >= containerWidth - scrollbarXWidth) {
scrollbarXLeft = containerWidth - scrollbarXWidth;
}
if (scrollbarYTop >= containerHeight - scrollbarYHeight) {
scrollbarYTop = containerHeight - scrollbarYHeight;
}
updateScrollbarCss();
};
updateCss();
var bindMouseScrollXHandler = function () {
var currentLeft,
currentPageX;
if (scrollbarXActive) {
$this.addClass('ps-active-x');
} else {
$this.removeClass('ps-active-x');
}
if (scrollbarYActive) {
$this.addClass('ps-active-y');
} else {
$this.removeClass('ps-active-y');
}
// Show scrollbars if needed after updated
if (!settings.suppressScrollX) {
$scrollbarXRail.show();
}
if (!settings.suppressScrollY) {
$scrollbarYRail.show();
}
}
function bindMouseScrollXHandler() {
var currentLeft;
var currentPageX;
$scrollbarX.bind('mousedown' + eventClassName, function (e) {
currentPageX = e.pageX;
@@ -246,15 +266,16 @@
e.preventDefault();
});
$(document).bind('mousemove' + eventClassName, function (e) {
$(ownerDocument).bind('mousemove' + eventClassName, function (e) {
if ($scrollbarXRail.hasClass('in-scrolling')) {
updateContentScrollLeft(currentLeft, e.pageX - currentPageX);
updateScrollLeft(currentLeft, e.pageX - currentPageX);
updateGeometry();
e.stopPropagation();
e.preventDefault();
}
});
$(document).bind('mouseup' + eventClassName, function (e) {
$(ownerDocument).bind('mouseup' + eventClassName, function (e) {
if ($scrollbarXRail.hasClass('in-scrolling')) {
$scrollbarXRail.removeClass('in-scrolling');
}
@@ -262,11 +283,11 @@
currentLeft =
currentPageX = null;
};
}
var bindMouseScrollYHandler = function () {
var currentTop,
currentPageY;
function bindMouseScrollYHandler() {
var currentTop;
var currentPageY;
$scrollbarY.bind('mousedown' + eventClassName, function (e) {
currentPageY = e.pageY;
@@ -276,15 +297,16 @@
e.preventDefault();
});
$(document).bind('mousemove' + eventClassName, function (e) {
$(ownerDocument).bind('mousemove' + eventClassName, function (e) {
if ($scrollbarYRail.hasClass('in-scrolling')) {
updateContentScrollTop(currentTop, e.pageY - currentPageY);
updateScrollTop(currentTop, e.pageY - currentPageY);
updateGeometry();
e.stopPropagation();
e.preventDefault();
}
});
$(document).bind('mouseup' + eventClassName, function (e) {
$(ownerDocument).bind('mouseup' + eventClassName, function (e) {
if ($scrollbarYRail.hasClass('in-scrolling')) {
$scrollbarYRail.removeClass('in-scrolling');
}
@@ -292,10 +314,10 @@
currentTop =
currentPageY = null;
};
}
// check if the default scrolling should be prevented.
var shouldPreventDefault = function (deltaX, deltaY) {
function shouldPreventDefault(deltaX, deltaY) {
var scrollTop = $this.scrollTop();
if (deltaX === 0) {
if (!scrollbarYActive) {
@@ -316,20 +338,41 @@
}
}
return true;
};
// bind handlers
var bindMouseWheelHandler = function () {
// FIXME: Backward compatibility.
// After e.deltaFactor applied, wheelSpeed should have smaller value.
// Currently, there's no way to change the settings after the scrollbar initialized.
// But if the way is implemented in the future, wheelSpeed should be reset.
settings.wheelSpeed /= 10;
}
function bindMouseWheelHandler() {
var shouldPrevent = false;
$this.bind('mousewheel' + eventClassName, function (e, deprecatedDelta, deprecatedDeltaX, deprecatedDeltaY) {
var deltaX = e.deltaX * e.deltaFactor || deprecatedDeltaX,
deltaY = e.deltaY * e.deltaFactor || deprecatedDeltaY;
function getDeltaFromEvent(e) {
var deltaX = e.originalEvent.deltaX;
var deltaY = -1 * e.originalEvent.deltaY;
if (typeof deltaX === "undefined" || typeof deltaY === "undefined") {
// OS X Safari
deltaX = -1 * e.originalEvent.wheelDeltaX / 6;
deltaY = e.originalEvent.wheelDeltaY / 6;
}
if (e.originalEvent.deltaMode && e.originalEvent.deltaMode === 1) {
// Firefox in deltaMode 1: Line scrolling
deltaX *= 10;
deltaY *= 10;
}
if (deltaX !== deltaX && deltaY !== deltaY/* NaN checks */) {
// IE in some mouse drivers
deltaX = 0;
deltaY = e.originalEvent.wheelDelta;
}
return [deltaX, deltaY];
}
function mousewheelHandler(e) {
var delta = getDeltaFromEvent(e);
var deltaX = delta[0];
var deltaY = delta[1];
shouldPrevent = false;
if (!settings.useBothWheelAxes) {
@@ -357,25 +400,23 @@
shouldPrevent = true;
}
// update bar position
updateBarSizeAndPosition();
updateGeometry();
shouldPrevent = (shouldPrevent || shouldPreventDefault(deltaX, deltaY));
if (shouldPrevent) {
e.stopPropagation();
e.preventDefault();
}
});
}
// fix Firefox scroll problem
$this.bind('MozMousePixelScroll' + eventClassName, function (e) {
if (shouldPrevent) {
e.preventDefault();
}
});
};
if (typeof window.onwheel !== "undefined") {
$this.bind('wheel' + eventClassName, mousewheelHandler);
} else if (typeof window.onmousewheel !== "undefined") {
$this.bind('mousewheel' + eventClassName, mousewheelHandler);
}
}
var bindKeyboardHandler = function () {
function bindKeyboardHandler() {
var hovered = false;
$this.bind('mouseenter' + eventClassName, function (e) {
hovered = true;
@@ -385,13 +426,26 @@
});
var shouldPrevent = false;
$(document).bind('keydown' + eventClassName, function (e) {
if (!hovered || $(document.activeElement).is(":input,[contenteditable]")) {
$(ownerDocument).bind('keydown' + eventClassName, function (e) {
if (e.isDefaultPrevented && e.isDefaultPrevented()) {
return;
}
var deltaX = 0,
deltaY = 0;
if (!hovered) {
return;
}
var activeElement = document.activeElement ? document.activeElement : ownerDocument.activeElement;
// go deeper if element is a webcomponent
while (activeElement.shadowRoot) {
activeElement = activeElement.shadowRoot.activeElement;
}
if ($(activeElement).is(":input,[contenteditable]")) {
return;
}
var deltaX = 0;
var deltaY = 0;
switch (e.which) {
case 37: // left
@@ -414,10 +468,18 @@
deltaY = -90;
break;
case 35: // end
deltaY = -containerHeight;
if (e.ctrlKey) {
deltaY = -contentHeight;
} else {
deltaY = -containerHeight;
}
break;
case 36: // home
deltaY = containerHeight;
if (e.ctrlKey) {
deltaY = $this.scrollTop();
} else {
deltaY = containerHeight;
}
break;
default:
return;
@@ -431,17 +493,17 @@
e.preventDefault();
}
});
};
}
var bindRailClickHandler = function () {
var stopPropagation = function (e) { e.stopPropagation(); };
function bindRailClickHandler() {
function stopPropagation(e) { e.stopPropagation(); }
$scrollbarY.bind('click' + eventClassName, stopPropagation);
$scrollbarYRail.bind('click' + eventClassName, function (e) {
var halfOfScrollbarLength = parseInt(scrollbarYHeight / 2, 10),
positionTop = e.pageY - $scrollbarYRail.offset().top - halfOfScrollbarLength,
maxPositionTop = containerHeight - scrollbarYHeight,
positionRatio = positionTop / maxPositionTop;
var halfOfScrollbarLength = int(scrollbarYHeight / 2);
var positionTop = e.pageY - $scrollbarYRail.offset().top - halfOfScrollbarLength;
var maxPositionTop = containerHeight - scrollbarYHeight;
var positionRatio = positionTop / maxPositionTop;
if (positionRatio < 0) {
positionRatio = 0;
@@ -454,10 +516,10 @@
$scrollbarX.bind('click' + eventClassName, stopPropagation);
$scrollbarXRail.bind('click' + eventClassName, function (e) {
var halfOfScrollbarLength = parseInt(scrollbarXWidth / 2, 10),
positionLeft = e.pageX - $scrollbarXRail.offset().left - halfOfScrollbarLength,
maxPositionLeft = containerWidth - scrollbarXWidth,
positionRatio = positionLeft / maxPositionLeft;
var halfOfScrollbarLength = int(scrollbarXWidth / 2);
var positionLeft = e.pageX - $scrollbarXRail.offset().left - halfOfScrollbarLength;
var maxPositionLeft = containerWidth - scrollbarXWidth;
var positionRatio = positionLeft / maxPositionLeft;
if (positionRatio < 0) {
positionRatio = 0;
@@ -467,58 +529,78 @@
$this.scrollLeft((contentWidth - containerWidth) * positionRatio);
});
};
}
// bind mobile touch handler
var bindMobileTouchHandler = function () {
var applyTouchMove = function (differenceX, differenceY) {
function bindTouchHandler(supportsTouch, supportsIePointer) {
function applyTouchMove(differenceX, differenceY) {
$this.scrollTop($this.scrollTop() - differenceY);
$this.scrollLeft($this.scrollLeft() - differenceX);
// update bar position
updateBarSizeAndPosition();
};
updateGeometry();
}
var startCoords = {},
startTime = 0,
speed = {},
breakingProcess = null,
inGlobalTouch = false;
var startOffset = {};
var startTime = 0;
var speed = {};
var breakingProcess = null;
var inGlobalTouch = false;
var inLocalTouch = false;
$(window).bind("touchstart" + eventClassName, function (e) {
function globalTouchStart(e) {
inGlobalTouch = true;
});
$(window).bind("touchend" + eventClassName, function (e) {
}
function globalTouchEnd(e) {
inGlobalTouch = false;
});
}
$this.bind("touchstart" + eventClassName, function (e) {
var touch = e.originalEvent.targetTouches[0];
startCoords.pageX = touch.pageX;
startCoords.pageY = touch.pageY;
startTime = (new Date()).getTime();
if (breakingProcess !== null) {
clearInterval(breakingProcess);
function getTouch(e) {
if (e.originalEvent.targetTouches) {
return e.originalEvent.targetTouches[0];
} else {
// Maybe IE pointer
return e.originalEvent;
}
}
function shouldHandle(e) {
var event = e.originalEvent;
if (event.targetTouches && event.targetTouches.length === 1) {
return true;
}
if (event.pointerType && event.pointerType !== 'mouse') {
return true;
}
return false;
}
function touchStart(e) {
if (shouldHandle(e)) {
inLocalTouch = true;
e.stopPropagation();
});
$this.bind("touchmove" + eventClassName, function (e) {
if (!inGlobalTouch && e.originalEvent.targetTouches.length === 1) {
var touch = e.originalEvent.targetTouches[0];
var touch = getTouch(e);
var currentCoords = {};
currentCoords.pageX = touch.pageX;
currentCoords.pageY = touch.pageY;
startOffset.pageX = touch.pageX;
startOffset.pageY = touch.pageY;
var differenceX = currentCoords.pageX - startCoords.pageX,
differenceY = currentCoords.pageY - startCoords.pageY;
startTime = (new Date()).getTime();
if (breakingProcess !== null) {
clearInterval(breakingProcess);
}
e.stopPropagation();
e.preventDefault();
}
}
function touchMove(e) {
if (!inGlobalTouch && inLocalTouch && shouldHandle(e)) {
var touch = getTouch(e);
var currentOffset = {pageX: touch.pageX, pageY: touch.pageY};
var differenceX = currentOffset.pageX - startOffset.pageX;
var differenceY = currentOffset.pageY - startOffset.pageY;
applyTouchMove(differenceX, differenceY);
startCoords = currentCoords;
startOffset = currentOffset;
var currentTime = (new Date()).getTime();
@@ -529,35 +611,64 @@
startTime = currentTime;
}
e.stopPropagation();
e.preventDefault();
}
});
$this.bind("touchend" + eventClassName, function (e) {
clearInterval(breakingProcess);
breakingProcess = setInterval(function () {
if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
clearInterval(breakingProcess);
return;
}
}
function touchEnd(e) {
if (!inGlobalTouch && inLocalTouch) {
inLocalTouch = false;
applyTouchMove(speed.x * 30, speed.y * 30);
clearInterval(breakingProcess);
breakingProcess = setInterval(function () {
if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
clearInterval(breakingProcess);
return;
}
speed.x *= 0.8;
speed.y *= 0.8;
}, 10);
});
};
applyTouchMove(speed.x * 30, speed.y * 30);
var bindScrollHandler = function () {
speed.x *= 0.8;
speed.y *= 0.8;
}, 10);
}
}
if (supportsTouch) {
$(window).bind("touchstart" + eventClassName, globalTouchStart);
$(window).bind("touchend" + eventClassName, globalTouchEnd);
$this.bind("touchstart" + eventClassName, touchStart);
$this.bind("touchmove" + eventClassName, touchMove);
$this.bind("touchend" + eventClassName, touchEnd);
}
if (supportsIePointer) {
if (window.PointerEvent) {
$(window).bind("pointerdown" + eventClassName, globalTouchStart);
$(window).bind("pointerup" + eventClassName, globalTouchEnd);
$this.bind("pointerdown" + eventClassName, touchStart);
$this.bind("pointermove" + eventClassName, touchMove);
$this.bind("pointerup" + eventClassName, touchEnd);
} else if (window.MSPointerEvent) {
$(window).bind("MSPointerDown" + eventClassName, globalTouchStart);
$(window).bind("MSPointerUp" + eventClassName, globalTouchEnd);
$this.bind("MSPointerDown" + eventClassName, touchStart);
$this.bind("MSPointerMove" + eventClassName, touchMove);
$this.bind("MSPointerUp" + eventClassName, touchEnd);
}
}
}
function bindScrollHandler() {
$this.bind('scroll' + eventClassName, function (e) {
updateBarSizeAndPosition();
updateGeometry();
});
};
}
var destroy = function () {
function destroy() {
$this.unbind(eventClassName);
$(window).unbind(eventClassName);
$(document).unbind(eventClassName);
$(ownerDocument).unbind(eventClassName);
$this.data('perfect-scrollbar', null);
$this.data('perfect-scrollbar-update', null);
$this.data('perfect-scrollbar-destroy', null);
@@ -589,86 +700,33 @@
scrollbarYLeft =
isRtl =
eventClassName = null;
};
var ieSupport = function (version) {
$this.addClass('ie').addClass('ie' + version);
var bindHoverHandlers = function () {
var mouseenter = function () {
$(this).addClass('hover');
};
var mouseleave = function () {
$(this).removeClass('hover');
};
$this.bind('mouseenter' + eventClassName, mouseenter).bind('mouseleave' + eventClassName, mouseleave);
$scrollbarXRail.bind('mouseenter' + eventClassName, mouseenter).bind('mouseleave' + eventClassName, mouseleave);
$scrollbarYRail.bind('mouseenter' + eventClassName, mouseenter).bind('mouseleave' + eventClassName, mouseleave);
$scrollbarX.bind('mouseenter' + eventClassName, mouseenter).bind('mouseleave' + eventClassName, mouseleave);
$scrollbarY.bind('mouseenter' + eventClassName, mouseenter).bind('mouseleave' + eventClassName, mouseleave);
};
var fixIe6ScrollbarPosition = function () {
updateScrollbarCss = function () {
var scrollbarXStyles = {left: scrollbarXLeft + $this.scrollLeft(), width: scrollbarXWidth};
if (isScrollbarXUsingBottom) {
scrollbarXStyles.bottom = scrollbarXBottom;
} else {
scrollbarXStyles.top = scrollbarXTop;
}
$scrollbarX.css(scrollbarXStyles);
var scrollbarYStyles = {top: scrollbarYTop + $this.scrollTop(), height: scrollbarYHeight};
if (isScrollbarYUsingRight) {
scrollbarYStyles.right = scrollbarYRight;
} else {
scrollbarYStyles.left = scrollbarYLeft;
}
$scrollbarY.css(scrollbarYStyles);
$scrollbarX.hide().show();
$scrollbarY.hide().show();
};
};
if (version === 6) {
bindHoverHandlers();
fixIe6ScrollbarPosition();
}
};
}
var supportsTouch = (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch);
var supportsIePointer = window.navigator.msMaxTouchPoints !== null;
var initialize = function () {
var ieMatch = navigator.userAgent.toLowerCase().match(/(msie) ([\w.]+)/);
if (ieMatch && ieMatch[1] === 'msie') {
// must be executed at first, because 'ieSupport' may addClass to the container
ieSupport(parseInt(ieMatch[2], 10));
}
updateBarSizeAndPosition();
function initialize() {
updateGeometry();
bindScrollHandler();
bindMouseScrollXHandler();
bindMouseScrollYHandler();
bindRailClickHandler();
if (supportsTouch) {
bindMobileTouchHandler();
}
if ($this.mousewheel) {
bindMouseWheelHandler();
bindMouseWheelHandler();
if (supportsTouch || supportsIePointer) {
bindTouchHandler(supportsTouch, supportsIePointer);
}
if (settings.useKeyboard) {
bindKeyboardHandler();
}
$this.data('perfect-scrollbar', $this);
$this.data('perfect-scrollbar-update', updateBarSizeAndPosition);
$this.data('perfect-scrollbar-update', updateGeometry);
$this.data('perfect-scrollbar-destroy', destroy);
};
}
// initialize
initialize();
return $this;
});
};
}));
});