Compare commits

...

15 Commits
0.6.0 ... 0.6.2

Author SHA1 Message Date
Hyunje Alex Jun
2cd65684e2 Release 0.6.2
1. Reattach rails when removed.
2. Check if parentNode exists when DOM-removing.
3. Consume mousewheel event for hovered textarea.
4. Other minor fixes.
2015-04-11 02:24:49 +09:00
Hyunje Alex Jun
a0b3754a0d Lint.
Missing semicolon.
2015-04-11 02:24:49 +09:00
Hyunje Alex Jun
dc7b14d0e1 Consume mousewheel event when there's hovered textarea.
Only when it needs to be scrolled.
2015-04-11 02:16:37 +09:00
Jun
a5aab04264 Merge pull request #309 from DanielApt/remove-patch
Check if parentNode exists
2015-04-08 18:53:16 +09:00
DanielApt
aca7683de1 Change tab size to 2 2015-04-02 10:18:46 +01:00
Hyunje Alex Jun
c21cfb6ed0 Add version information to built files. 2015-04-02 02:10:25 +09:00
Hyunje Alex Jun
e4b21c7069 Remove -ms-filter for opacity.
The plugin doesn't support old IEs.
2015-04-02 01:12:44 +09:00
DanielApt
bb58ab98e3 Fix failing test 2015-03-27 18:28:51 +00:00
DanielApt
633f1f53d3 Check if parentNode exists
We need to check if parentNode exists, as in some scenarios it does not (e.g. phantomjs < 2)
2015-03-27 16:58:10 +00:00
Hyunje Alex Jun
4a7f27356a Change the way to re-attach rails when they're detached.
Instead of destroying and re-initialising the plugin, just re-append
them.
2015-03-11 22:07:14 +09:00
Hyunje Alex Jun
2e071274db Release 0.6.1
1. jQuery adaptor error fix.
2015-03-06 02:02:25 +09:00
Jun
b23ad2834e Merge pull request #297 from BR0kEN-/issue-296
Fixed an issue #296 with undefined function in jQuery plugin.
2015-03-06 00:50:35 +09:00
Sergey Bondarenko
cbdf812de8 Issue #296 has been fixed 2015-03-05 14:41:12 +02:00
Jun
5e363b876f Merge pull request #293 from DanielApt/patch-1
#277 has been closed, remove reference to it in README.md
2015-03-03 03:00:20 +09:00
DanielApt
cbf96b3302 #227 has been closed, remove reference to it in README.md 2015-03-02 17:57:00 +00:00
9 changed files with 54 additions and 31 deletions

View File

@@ -4,9 +4,6 @@ Minimalistic but perfect custom scrollbar plugin
[![Travis CI](https://travis-ci.org/noraesae/perfect-scrollbar.svg?branch=master)](https://travis-ci.org/noraesae/perfect-scrollbar)
**The plugin is currently changing quickly in the master branch.
Please refer to the related issue [#227](https://github.com/noraesae/perfect-scrollbar/issues/277).**
If you want information of old versions&lt;0.6.0, please refer to
[an old documentation](https://github.com/noraesae/perfect-scrollbar/tree/0.5.9).

View File

@@ -5,6 +5,7 @@ var gulp = require('gulp')
, bump = require('gulp-bump')
, connect = require('gulp-connect')
, eslint = require('gulp-eslint')
, insert = require('gulp-insert')
, rename = require('gulp-rename')
, rimraf = require('gulp-rimraf')
, sass = require('gulp-sass')
@@ -12,6 +13,8 @@ var gulp = require('gulp')
, uglify = require('gulp-uglify')
, zip = require('gulp-zip');
var version = '/* perfect-scrollbar v' + require('./package').version + ' */\n';
gulp.task('lint', function () {
return gulp.src(['./src/**/*.js', './gulpfile.js'])
.pipe(eslint())
@@ -39,6 +42,7 @@ function browserified() {
gulp.task('js', ['clean:js'], function () {
return gulp.src('./src/js/adaptor/*.js')
.pipe(browserified())
.pipe(insert.prepend(version))
.pipe(rename(function (path) {
if (path.basename === 'global') {
path.basename = 'perfect-scrollbar';
@@ -54,6 +58,7 @@ gulp.task('js:min', ['clean:js:min'], function () {
return gulp.src('./src/js/adaptor/*.js')
.pipe(browserified())
.pipe(uglify())
.pipe(insert.prepend(version))
.pipe(rename(function (path) {
if (path.basename === 'global') {
path.basename = 'perfect-scrollbar.min';
@@ -77,6 +82,7 @@ gulp.task('clean:css:min', function () {
gulp.task('sass', ['clean:css'], function () {
return gulp.src('./src/css/main.scss')
.pipe(sass())
.pipe(insert.prepend(version))
.pipe(rename('perfect-scrollbar.css'))
.pipe(gulp.dest('./dist/css'))
.pipe(connect.reload());
@@ -85,6 +91,7 @@ gulp.task('sass', ['clean:css'], function () {
gulp.task('sass:min', ['clean:css:min'], function () {
return gulp.src('./src/css/main.scss')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(insert.prepend(version))
.pipe(rename('perfect-scrollbar.min.css'))
.pipe(gulp.dest('./dist/css'));
});

View File

@@ -1,6 +1,6 @@
{
"name": "perfect-scrollbar",
"version": "0.6.0",
"version": "0.6.2",
"description": "Minimalistic but perfect custom scrollbar plugin",
"author": "Hyunje Alex Jun <me@noraesae.net>",
"contributors": [
@@ -32,6 +32,7 @@
"gulp-bump": "^0.1.11",
"gulp-connect": "^2.2.0",
"gulp-eslint": "^0.2.0",
"gulp-insert": "^0.4.0",
"gulp-rename": "^1.2.0",
"gulp-rimraf": "^0.1.1",
"gulp-sass": "^1.3.1",

View File

@@ -4,13 +4,6 @@ $ps-bar-default: #aaa;
$ps-bar-hover: #999;
// Helper mixins
@mixin opacity($o) {
$IEValue: $o * 100;
opacity: $o;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity="+$IEValue+")";
filter: alpha(opacity=$IEValue);
}
@mixin border-radius($r) {
-webkit-border-radius: $r;
-moz-border-radius: $r;
@@ -30,13 +23,13 @@ $ps-bar-hover: #999;
display: none;
position: absolute; /* please don't change 'position' */
@include border-radius(4px);
@include opacity(0);
opacity: 0;
@include transition(background-color .2s linear, opacity .2s linear);
}
@mixin scrollbar-rail-hover {
background-color: $ps-rail-hover;
@include opacity(0.9);
opacity: 0.9;
}
@mixin scrollbar-default {
@@ -107,7 +100,7 @@ $ps-bar-hover: #999;
>.ps-scrollbar-x-rail,
>.ps-scrollbar-y-rail {
@include opacity(0.6);
opacity: 0.6;
}
>.ps-scrollbar-x-rail:hover {

View File

@@ -28,7 +28,7 @@ function mountJQuery(jQuery) {
}
}
return $(this);
return jQuery(this);
});
};
}

View File

@@ -70,6 +70,8 @@ exports.remove = function (element) {
if (typeof element.remove !== 'undefined') {
element.remove();
} else {
element.parentNode.removeChild(element);
if (element.parentNode) {
element.parentNode.removeChild(element);
}
}
};

View File

@@ -58,6 +58,27 @@ function bindMouseWheelHandler(element, i) {
return [deltaX, deltaY];
}
function shouldBeConsumedByTextarea(deltaX, deltaY) {
var hoveredTextarea = element.querySelector('textarea:hover');
if (hoveredTextarea) {
var maxScrollTop = hoveredTextarea.scrollHeight - hoveredTextarea.clientHeight;
if (maxScrollTop > 0) {
if (!(hoveredTextarea.scrollTop === 0 && deltaY > 0) &&
!(hoveredTextarea.scrollTop === maxScrollTop && deltaY < 0)) {
return true;
}
}
var maxScrollLeft = hoveredTextarea.scrollLeft - hoveredTextarea.clientWidth;
if (maxScrollLeft > 0) {
if (!(hoveredTextarea.scrollLeft === 0 && deltaX < 0) &&
!(hoveredTextarea.scrollLeft === maxScrollLeft && deltaX > 0)) {
return true;
}
}
}
return false;
}
function mousewheelHandler(e) {
// FIXME: this is a quick fix for the select problem in FF and IE.
// If there comes an effective way to deal with the problem,
@@ -71,6 +92,10 @@ function bindMouseWheelHandler(element, i) {
var deltaX = delta[0];
var deltaY = delta[1];
if (shouldBeConsumedByTextarea(deltaX, deltaY)) {
return;
}
shouldPrevent = false;
if (!i.settings.useBothWheelAxes) {
// deltaX will only be used for horizontal scrolling and deltaY will

View File

@@ -60,6 +60,13 @@ module.exports = function (element) {
i.contentWidth = element.scrollWidth;
i.contentHeight = element.scrollHeight;
if (!element.contains(i.scrollbarXRail)) {
d.appendTo(i.scrollbarXRail, element);
}
if (!element.contains(i.scrollbarYRail)) {
d.appendTo(i.scrollbarYRail, element);
}
if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) {
i.scrollbarXActive = true;
i.railXWidth = i.containerWidth - i.railXMarginWidth;

View File

@@ -4,27 +4,18 @@
'use strict';
var d = require('../lib/dom')
, destroy = require('./destroy')
, initialize = require('./initialize')
, instances = require('./instances')
, updateGeometry = require('./update-geometry');
module.exports = function (element) {
var i = instances.get(element);
if (!i.scrollbarXRail || !element.contains(i.scrollbarXRail) ||
!i.scrollbarYRail || !element.contains(i.scrollbarYRail)) {
// If there's something wrong in the plugin, re-initialise.
destroy(element);
initialize(element);
} else {
// Hide scrollbars not to affect scrollWidth and scrollHeight
d.css(i.scrollbarXRail, 'display', 'none');
d.css(i.scrollbarYRail, 'display', 'none');
// Hide scrollbars not to affect scrollWidth and scrollHeight
d.css(i.scrollbarXRail, 'display', 'none');
d.css(i.scrollbarYRail, 'display', 'none');
updateGeometry(element);
updateGeometry(element);
d.css(i.scrollbarXRail, 'display', 'block');
d.css(i.scrollbarYRail, 'display', 'block');
}
d.css(i.scrollbarXRail, 'display', 'block');
d.css(i.scrollbarYRail, 'display', 'block');
};