Skip to content

Commit 37ef155

Browse files
author
unknown
committed
0.6.9
1 parent 13f617c commit 37ef155

33 files changed

+269
-212
lines changed

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The MIT License (MIT) Copyright (c) 2016 Hyunje Alex Jun and other contributors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ require.config({
218218
and load `perfectScrollbar` in the initialiser of your app:
219219

220220
```javascript
221-
# for vanilla JS:
221+
// for vanilla JS:
222222
window.Ps = require('perfectScrollbar');
223223

224-
# for jQuery:
224+
// for jQuery:
225225
require('perfectScrollbarJQuery');
226226
```
227227

@@ -250,12 +250,12 @@ function (angular) {
250250
And initialise perfectScrollbar in a controller:
251251

252252
```javascript
253-
# by vanilla JS:
253+
// by vanilla JS:
254254
var container = document.getElementById('imgLoader');
255255
Ps.initialize(container);
256256
Ps.update(container);
257257

258-
# or by jQuery:
258+
// or by jQuery:
259259
var imgLoader = $("#imgLoader")
260260
imgLoader.perfectScrollbar();
261261
```
@@ -316,6 +316,36 @@ When set to false, when clicking on a rail, the click event will be allowed to p
316316
When set to true, you can scroll the container by selecting text and move the cursor.
317317
**Default: false**
318318

319+
### theme
320+
A string. It's a class name added to the container element. The class name is prepended with `ps-theme-`. So default theme class name is `ps-theme-default`. In order to create custom themes with scss use `ps-container($theme)` mixin, where `$theme` is a scss map.
321+
**Default: 'default'**
322+
323+
**Example 1:**
324+
325+
Add `theme` parameter:
326+
```javascript
327+
Ps.initialize(container, {
328+
theme: 'my-theme-name'
329+
});
330+
```
331+
Create a class name prefixed with `.ps-theme-`. Include `ps-container()` mixin. It's recommended to use `map-merge()` to extend `$ps-theme-default` map with your custom styles.
332+
```css#
333+
.ps-theme-my-theme-name {
334+
@include ps-container(map-merge($ps-theme-default, (
335+
border-radius: 0,
336+
scrollbar-x-rail-height: 20px,
337+
scrollbar-x-height: 20px,
338+
scrollbar-y-rail-width: 20px,
339+
scrollbar-y-width: 20px,)
340+
));
341+
}
342+
```
343+
344+
**Example 2:**
345+
346+
Alternatively, if you don't want to create your own themes, but only modify the default one, you could simply overwrite `$ps-*` variables with your own values. In this case `theme` parameter is not required when calling `.initialize()` method. Remember do define your own variables before the `theme.scss` file is imported.
347+
348+
319349
## Events
320350

321351
perfect-scrollbar dispatches custom events.
@@ -396,7 +426,7 @@ For common problems there is a
396426

397427
## License
398428

399-
The MIT License (MIT) Copyright (c) 2015 Hyunje Alex Jun and other contributors.
429+
The MIT License (MIT) Copyright (c) 2016 Hyunje Alex Jun and other contributors.
400430

401431
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:
402432

examples/custom-theme.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
5+
<title>perfect-scrollbar example</title>
6+
<link href="../dist/css/perfect-scrollbar.css" rel="stylesheet">
7+
<script src="../dist/js/perfect-scrollbar.js"></script>
8+
<style>
9+
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 600px; height: 400px; overflow: auto; }
10+
.contentHolder .content { background-image: url('./azusa.jpg'); width: 1280px; height: 720px; }
11+
</style>
12+
</head>
13+
<body>
14+
<div id="Default" class="contentHolder">
15+
<div class="content">
16+
</div>
17+
</div>
18+
<script>
19+
var $ = document.querySelector.bind(document);
20+
window.onload = function () {
21+
Ps.initialize($('#Default'), {
22+
theme: 'big-and-ugly'
23+
});
24+
};
25+
</script>
26+
</body>
27+
</html>

gulpfile.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var gulp = require('gulp')
1313
, source = require('vinyl-source-stream')
1414
, stream = require('event-stream')
1515
, uglify = require('gulp-uglify')
16+
, autoprefixer = require('gulp-autoprefixer')
1617
, zip = require('gulp-zip');
1718

1819
var version = '/* perfect-scrollbar v' + require('./package').version + ' */\n';
@@ -37,6 +38,11 @@ var jsEntries = [
3738
'./src/js/adaptor/jquery.js'
3839
];
3940

41+
var autoPrefixerConfig = {
42+
browsers: ['> 0%'], // '> 0%' forces autoprefixer to use all the possible prefixes. See https://github.com/ai/browserslist#queries for more details. IMO 'last 3 versions' would be good enough.
43+
cascade: false
44+
};
45+
4046
gulp.task('js', ['clean:js'], function () {
4147
var tasks = jsEntries.map(function (src) {
4248
return browserify([src]).bundle()
@@ -87,6 +93,7 @@ gulp.task('clean:css:min', function () {
8793
gulp.task('css', ['clean:css'], function () {
8894
return gulp.src('./src/css/main.scss')
8995
.pipe(sass())
96+
.pipe(autoprefixer(autoPrefixerConfig))
9097
.pipe(insert.prepend(version))
9198
.pipe(rename('perfect-scrollbar.css'))
9299
.pipe(gulp.dest('./dist/css'))
@@ -96,6 +103,7 @@ gulp.task('css', ['clean:css'], function () {
96103
gulp.task('css:min', ['clean:css:min'], function () {
97104
return gulp.src('./src/css/main.scss')
98105
.pipe(sass({outputStyle: 'compressed'}))
106+
.pipe(autoprefixer(autoPrefixerConfig))
99107
.pipe(insert.prepend(version))
100108
.pipe(rename('perfect-scrollbar.min.css'))
101109
.pipe(gulp.dest('./dist/css'));

index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
2-
* Licensed under the MIT License
3-
*/
41
'use strict';
52

63
module.exports = require('./src/js/main');

jquery.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
2-
* Licensed under the MIT License
3-
*/
41
'use strict';
52

63
module.exports = require('./src/js/adaptor/jquery');

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "perfect-scrollbar",
3-
"version": "0.6.8",
3+
"version": "0.6.9",
44
"description": "Minimalistic but perfect custom scrollbar plugin",
55
"author": "Hyunje Alex Jun <[email protected]>",
66
"contributors": [
@@ -31,6 +31,7 @@
3131
"del": "^2.0.2",
3232
"event-stream": "^3.3.1",
3333
"gulp": "^3.9.0",
34+
"gulp-autoprefixer": "^3.1.0",
3435
"gulp-connect": "^2.2.0",
3536
"gulp-eslint": "^1.0.0",
3637
"gulp-insert": "^0.5.0",

src/css/main.scss

Lines changed: 3 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,3 @@
1-
// Colors
2-
$ps-rail-hover: #eee;
3-
$ps-bar-default: #aaa;
4-
$ps-bar-hover: #999;
5-
6-
// Helper mixins
7-
@mixin border-radius($r) {
8-
-webkit-border-radius: $r;
9-
-moz-border-radius: $r;
10-
-ms-border-radius: $r;
11-
border-radius: $r;
12-
}
13-
14-
@mixin transition($t...) {
15-
-webkit-transition: $t;
16-
-moz-transition: $t;
17-
-o-transition: $t;
18-
transition: $t;
19-
}
20-
21-
// Scrollbar mixins
22-
@mixin scrollbar-rail-default {
23-
display: none;
24-
position: absolute; /* please don't change 'position' */
25-
@include border-radius(4px);
26-
opacity: 0;
27-
@include transition(background-color .2s linear, opacity .2s linear);
28-
}
29-
30-
@mixin scrollbar-rail-hover {
31-
background-color: $ps-rail-hover;
32-
opacity: 0.9;
33-
}
34-
35-
@mixin scrollbar-default {
36-
position: absolute; /* please don't change 'position' */
37-
background-color: $ps-bar-default;
38-
@include border-radius(4px);
39-
@include transition(background-color .2s linear);
40-
}
41-
42-
@mixin scrollbar-hover {
43-
background-color: $ps-bar-hover;
44-
}
45-
46-
@mixin in-scrolling {
47-
&.ps-in-scrolling {
48-
pointer-events: none;
49-
&.ps-x>.ps-scrollbar-x-rail{
50-
@include scrollbar-rail-hover;
51-
>.ps-scrollbar-x {
52-
@include scrollbar-hover;
53-
}
54-
}
55-
&.ps-y>.ps-scrollbar-y-rail {
56-
@include scrollbar-rail-hover;
57-
>.ps-scrollbar-y {
58-
@include scrollbar-hover;
59-
}
60-
}
61-
}
62-
}
63-
64-
.ps-container {
65-
-ms-touch-action: none;
66-
overflow: hidden !important;
67-
68-
&.ps-active-x > .ps-scrollbar-x-rail,
69-
&.ps-active-y > .ps-scrollbar-y-rail {
70-
display: block;
71-
}
72-
73-
@include in-scrolling;
74-
75-
>.ps-scrollbar-x-rail {
76-
@include scrollbar-rail-default;
77-
bottom: 3px; /* there must be 'bottom' for ps-scrollbar-x-rail */
78-
height: 8px;
79-
80-
>.ps-scrollbar-x {
81-
@include scrollbar-default;
82-
bottom: 0; /* there must be 'bottom' for ps-scrollbar-x */
83-
height: 8px;
84-
}
85-
}
86-
87-
>.ps-scrollbar-y-rail {
88-
@include scrollbar-rail-default;
89-
right: 3px; /* there must be 'right' for ps-scrollbar-y-rail */
90-
width: 8px;
91-
92-
>.ps-scrollbar-y {
93-
@include scrollbar-default;
94-
right: 0; /* there must be 'right' for ps-scrollbar-y */
95-
width: 8px;
96-
}
97-
}
98-
99-
&:hover {
100-
@include in-scrolling;
101-
102-
>.ps-scrollbar-x-rail,
103-
>.ps-scrollbar-y-rail {
104-
opacity: 0.6;
105-
}
106-
107-
>.ps-scrollbar-x-rail:hover {
108-
@include scrollbar-rail-hover;
109-
110-
>.ps-scrollbar-x {
111-
@include scrollbar-hover;
112-
}
113-
}
114-
115-
>.ps-scrollbar-y-rail:hover {
116-
@include scrollbar-rail-hover;
117-
118-
>.ps-scrollbar-y {
119-
@include scrollbar-hover;
120-
}
121-
}
122-
}
123-
}
1+
@import 'variables';
2+
@import 'mixins';
3+
@import 'themes';

0 commit comments

Comments
 (0)