Skip to content

Commit 43b8bb7

Browse files
author
unknown
committed
0.6.5
1 parent 764ec03 commit 43b8bb7

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "perfect-scrollbar",
3-
"version": "0.6.4",
3+
"version": "0.6.5",
44
"description": "Minimalistic but perfect custom scrollbar plugin",
55
"author": "Hyunje Alex Jun <[email protected]>",
66
"contributors": [

src/js/lib/dom.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
*/
44
'use strict';
55

6-
exports.e = function (tagName, className) {
6+
var DOM = {};
7+
8+
DOM.e = function (tagName, className) {
79
var element = document.createElement(tagName);
810
element.className = className;
911
return element;
1012
};
1113

12-
exports.appendTo = function (child, parent) {
14+
DOM.appendTo = function (child, parent) {
1315
parent.appendChild(child);
1416
return child;
1517
};
@@ -37,7 +39,7 @@ function cssMultiSet(element, obj) {
3739
return element;
3840
}
3941

40-
exports.css = function (element, styleNameOrObject, styleValue) {
42+
DOM.css = function (element, styleNameOrObject, styleValue) {
4143
if (typeof styleNameOrObject === 'object') {
4244
// multiple set with object
4345
return cssMultiSet(element, styleNameOrObject);
@@ -50,7 +52,7 @@ exports.css = function (element, styleNameOrObject, styleValue) {
5052
}
5153
};
5254

53-
exports.matches = function (element, query) {
55+
DOM.matches = function (element, query) {
5456
if (typeof element.matches !== 'undefined') {
5557
return element.matches(query);
5658
} else {
@@ -66,7 +68,7 @@ exports.matches = function (element, query) {
6668
}
6769
};
6870

69-
exports.remove = function (element) {
71+
DOM.remove = function (element) {
7072
if (typeof element.remove !== 'undefined') {
7173
element.remove();
7274
} else {
@@ -75,3 +77,11 @@ exports.remove = function (element) {
7577
}
7678
}
7779
};
80+
81+
DOM.queryChildren = function (element, selector) {
82+
return Array.prototype.filter.call(element.childNodes, function (child) {
83+
return DOM.matches(child, selector);
84+
});
85+
};
86+
87+
module.exports = DOM;

src/js/plugin/handler/keyboard.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ function bindKeyboardHandler(element, i) {
8080
deltaY = 90;
8181
break;
8282
case 32: // space bar
83+
if (e.shiftKey) {
84+
deltaY = 90;
85+
} else {
86+
deltaY = -90;
87+
}
88+
break;
8389
case 34: // page down
8490
deltaY = -90;
8591
break;

src/js/plugin/update-geometry.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,23 @@ module.exports = function (element) {
6060
i.contentWidth = element.scrollWidth;
6161
i.contentHeight = element.scrollHeight;
6262

63+
var existingRails;
6364
if (!element.contains(i.scrollbarXRail)) {
65+
existingRails = d.queryChildren(element, '.ps-scrollbar-x-rail');
66+
if (existingRails.length > 0) {
67+
existingRails.forEach(function (rail) {
68+
d.remove(rail);
69+
});
70+
}
6471
d.appendTo(i.scrollbarXRail, element);
6572
}
6673
if (!element.contains(i.scrollbarYRail)) {
74+
existingRails = d.queryChildren(element, '.ps-scrollbar-y-rail');
75+
if (existingRails.length > 0) {
76+
existingRails.forEach(function (rail) {
77+
d.remove(rail);
78+
});
79+
}
6780
d.appendTo(i.scrollbarYRail, element);
6881
}
6982

0 commit comments

Comments
 (0)