Skip to content

Commit

Permalink
0.6.9
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Mar 24, 2022
1 parent 13f617c commit 37ef155
Show file tree
Hide file tree
Showing 33 changed files with 269 additions and 212 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT) Copyright (c) 2016 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:

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.
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ require.config({
and load `perfectScrollbar` in the initialiser of your app:

```javascript
# for vanilla JS:
// for vanilla JS:
window.Ps = require('perfectScrollbar');

# for jQuery:
// for jQuery:
require('perfectScrollbarJQuery');
```

Expand Down Expand Up @@ -250,12 +250,12 @@ function (angular) {
And initialise perfectScrollbar in a controller:

```javascript
# by vanilla JS:
// by vanilla JS:
var container = document.getElementById('imgLoader');
Ps.initialize(container);
Ps.update(container);

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

### theme
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.
**Default: 'default'**

**Example 1:**

Add `theme` parameter:
```javascript
Ps.initialize(container, {
theme: 'my-theme-name'
});
```
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.
```css#
.ps-theme-my-theme-name {
@include ps-container(map-merge($ps-theme-default, (
border-radius: 0,
scrollbar-x-rail-height: 20px,
scrollbar-x-height: 20px,
scrollbar-y-rail-width: 20px,
scrollbar-y-width: 20px,)
));
}
```

**Example 2:**

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.


## Events

perfect-scrollbar dispatches custom events.
Expand Down Expand Up @@ -396,7 +426,7 @@ For common problems there is a

## License

The MIT License (MIT) Copyright (c) 2015 Hyunje Alex Jun and other contributors.
The MIT License (MIT) Copyright (c) 2016 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:

Expand Down
27 changes: 27 additions & 0 deletions examples/custom-theme.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>perfect-scrollbar example</title>
<link href="../dist/css/perfect-scrollbar.css" rel="stylesheet">
<script src="../dist/js/perfect-scrollbar.js"></script>
<style>
.contentHolder { position:relative; margin:0px auto; padding:0px; width: 600px; height: 400px; overflow: auto; }
.contentHolder .content { background-image: url('./azusa.jpg'); width: 1280px; height: 720px; }
</style>
</head>
<body>
<div id="Default" class="contentHolder">
<div class="content">
</div>
</div>
<script>
var $ = document.querySelector.bind(document);
window.onload = function () {
Ps.initialize($('#Default'), {
theme: 'big-and-ugly'
});
};
</script>
</body>
</html>
8 changes: 8 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var gulp = require('gulp')
, source = require('vinyl-source-stream')
, stream = require('event-stream')
, uglify = require('gulp-uglify')
, autoprefixer = require('gulp-autoprefixer')
, zip = require('gulp-zip');

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

var autoPrefixerConfig = {
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.
cascade: false
};

gulp.task('js', ['clean:js'], function () {
var tasks = jsEntries.map(function (src) {
return browserify([src]).bundle()
Expand Down Expand Up @@ -87,6 +93,7 @@ gulp.task('clean:css:min', function () {
gulp.task('css', ['clean:css'], function () {
return gulp.src('./src/css/main.scss')
.pipe(sass())
.pipe(autoprefixer(autoPrefixerConfig))
.pipe(insert.prepend(version))
.pipe(rename('perfect-scrollbar.css'))
.pipe(gulp.dest('./dist/css'))
Expand All @@ -96,6 +103,7 @@ gulp.task('css', ['clean:css'], function () {
gulp.task('css:min', ['clean:css:min'], function () {
return gulp.src('./src/css/main.scss')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(autoprefixer(autoPrefixerConfig))
.pipe(insert.prepend(version))
.pipe(rename('perfect-scrollbar.min.css'))
.pipe(gulp.dest('./dist/css'));
Expand Down
3 changes: 0 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
* Licensed under the MIT License
*/
'use strict';

module.exports = require('./src/js/main');
3 changes: 0 additions & 3 deletions jquery.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
* Licensed under the MIT License
*/
'use strict';

module.exports = require('./src/js/adaptor/jquery');
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "perfect-scrollbar",
"version": "0.6.8",
"version": "0.6.9",
"description": "Minimalistic but perfect custom scrollbar plugin",
"author": "Hyunje Alex Jun <[email protected]>",
"contributors": [
Expand Down Expand Up @@ -31,6 +31,7 @@
"del": "^2.0.2",
"event-stream": "^3.3.1",
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-connect": "^2.2.0",
"gulp-eslint": "^1.0.0",
"gulp-insert": "^0.5.0",
Expand Down
126 changes: 3 additions & 123 deletions src/css/main.scss
Original file line number Diff line number Diff line change
@@ -1,123 +1,3 @@
// Colors
$ps-rail-hover: #eee;
$ps-bar-default: #aaa;
$ps-bar-hover: #999;

// Helper mixins
@mixin border-radius($r) {
-webkit-border-radius: $r;
-moz-border-radius: $r;
-ms-border-radius: $r;
border-radius: $r;
}

@mixin transition($t...) {
-webkit-transition: $t;
-moz-transition: $t;
-o-transition: $t;
transition: $t;
}

// Scrollbar mixins
@mixin scrollbar-rail-default {
display: none;
position: absolute; /* please don't change 'position' */
@include border-radius(4px);
opacity: 0;
@include transition(background-color .2s linear, opacity .2s linear);
}

@mixin scrollbar-rail-hover {
background-color: $ps-rail-hover;
opacity: 0.9;
}

@mixin scrollbar-default {
position: absolute; /* please don't change 'position' */
background-color: $ps-bar-default;
@include border-radius(4px);
@include transition(background-color .2s linear);
}

@mixin scrollbar-hover {
background-color: $ps-bar-hover;
}

@mixin in-scrolling {
&.ps-in-scrolling {
pointer-events: none;
&.ps-x>.ps-scrollbar-x-rail{
@include scrollbar-rail-hover;
>.ps-scrollbar-x {
@include scrollbar-hover;
}
}
&.ps-y>.ps-scrollbar-y-rail {
@include scrollbar-rail-hover;
>.ps-scrollbar-y {
@include scrollbar-hover;
}
}
}
}

.ps-container {
-ms-touch-action: none;
overflow: hidden !important;

&.ps-active-x > .ps-scrollbar-x-rail,
&.ps-active-y > .ps-scrollbar-y-rail {
display: block;
}

@include in-scrolling;

>.ps-scrollbar-x-rail {
@include scrollbar-rail-default;
bottom: 3px; /* there must be 'bottom' for ps-scrollbar-x-rail */
height: 8px;

>.ps-scrollbar-x {
@include scrollbar-default;
bottom: 0; /* there must be 'bottom' for ps-scrollbar-x */
height: 8px;
}
}

>.ps-scrollbar-y-rail {
@include scrollbar-rail-default;
right: 3px; /* there must be 'right' for ps-scrollbar-y-rail */
width: 8px;

>.ps-scrollbar-y {
@include scrollbar-default;
right: 0; /* there must be 'right' for ps-scrollbar-y */
width: 8px;
}
}

&:hover {
@include in-scrolling;

>.ps-scrollbar-x-rail,
>.ps-scrollbar-y-rail {
opacity: 0.6;
}

>.ps-scrollbar-x-rail:hover {
@include scrollbar-rail-hover;

>.ps-scrollbar-x {
@include scrollbar-hover;
}
}

>.ps-scrollbar-y-rail:hover {
@include scrollbar-rail-hover;

>.ps-scrollbar-y {
@include scrollbar-hover;
}
}
}
}
@import 'variables';
@import 'mixins';
@import 'themes';
Loading

0 comments on commit 37ef155

Please sign in to comment.