Skip to content

Commit

Permalink
1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Mar 24, 2022
1 parent 717f1d8 commit cb871a0
Show file tree
Hide file tree
Showing 18 changed files with 401 additions and 342 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ I hope you love it!

## Demo

It's on the [GitHub Pages](http://utatti.github.com/perfect-scrollbar/).
It's on the [GitHub Pages](http://utatti.github.io/perfect-scrollbar/).

## Table of Contents

Expand Down
16 changes: 10 additions & 6 deletions css/perfect-scrollbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@
opacity: 0.6;
}

.ps__rail-x:hover,
.ps__rail-y:hover,
.ps__rail-x:focus,
.ps__rail-y:focus {
.ps .ps__rail-x:hover,
.ps .ps__rail-y:hover,
.ps .ps__rail-x:focus,
.ps .ps__rail-y:focus,
.ps .ps__rail-x.ps--clicking,
.ps .ps__rail-y.ps--clicking {
background-color: #eee;
opacity: 0.9;
}
Expand Down Expand Up @@ -87,13 +89,15 @@
}

.ps__rail-x:hover > .ps__thumb-x,
.ps__rail-x:focus > .ps__thumb-x {
.ps__rail-x:focus > .ps__thumb-x,
.ps__rail-x.ps--clicking .ps__thumb-x {
background-color: #999;
height: 11px;
}

.ps__rail-y:hover > .ps__thumb-y,
.ps__rail-y:focus > .ps__thumb-y {
.ps__rail-y:focus > .ps__thumb-y,
.ps__rail-y.ps--clicking .ps__thumb-y {
background-color: #999;
width: 11px;
}
Expand Down
44 changes: 28 additions & 16 deletions dist/perfect-scrollbar.common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* perfect-scrollbar v1.3.0
* (c) 2017 Hyunje Jun
* perfect-scrollbar v1.4.0
* (c) 2018 Hyunje Jun
* @license MIT
*/
'use strict';
Expand Down Expand Up @@ -30,6 +30,7 @@ var elMatches =
typeof Element !== 'undefined' &&
(Element.prototype.matches ||
Element.prototype.webkitMatchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector);

function matches(element, query) {
Expand Down Expand Up @@ -64,6 +65,7 @@ var cls = {
},
state: {
focus: 'ps--focus',
clicking: 'ps--clicking',
active: function (x) { return ("ps--active-" + x); },
scrolling: function (x) { return ("ps--scrolling-" + x); },
},
Expand Down Expand Up @@ -318,6 +320,7 @@ var env = {

var updateGeometry = function(i) {
var element = i.element;
var roundedScrollTop = Math.floor(element.scrollTop);

i.containerWidth = element.clientWidth;
i.containerHeight = element.clientHeight;
Expand Down Expand Up @@ -369,7 +372,7 @@ var updateGeometry = function(i) {
toInt(i.railYHeight * i.containerHeight / i.contentHeight)
);
i.scrollbarYTop = toInt(
element.scrollTop *
roundedScrollTop *
(i.railYHeight - i.scrollbarYHeight) /
(i.contentHeight - i.containerHeight)
);
Expand Down Expand Up @@ -416,6 +419,8 @@ function getThumbSize(i, thumbSize) {

function updateCss(element, i) {
var xRailOffset = { width: i.railXWidth };
var roundedScrollTop = Math.floor(element.scrollTop);

if (i.isRtl) {
xRailOffset.left =
i.negativeScrollAdjustment +
Expand All @@ -426,13 +431,13 @@ function updateCss(element, i) {
xRailOffset.left = element.scrollLeft;
}
if (i.isScrollbarXUsingBottom) {
xRailOffset.bottom = i.scrollbarXBottom - element.scrollTop;
xRailOffset.bottom = i.scrollbarXBottom - roundedScrollTop;
} else {
xRailOffset.top = i.scrollbarXTop + element.scrollTop;
xRailOffset.top = i.scrollbarXTop + roundedScrollTop;
}
set(i.scrollbarXRail, xRailOffset);

var yRailOffset = { top: element.scrollTop, height: i.railYHeight };
var yRailOffset = { top: roundedScrollTop, height: i.railYHeight };
if (i.isScrollbarYUsingRight) {
if (i.isRtl) {
yRailOffset.right =
Expand Down Expand Up @@ -507,7 +512,8 @@ var dragThumb = function(i) {
'scrollbarX',
'scrollbarXWidth',
'scrollLeft',
'x' ]);
'x',
'scrollbarXRail' ]);
bindMouseScrollHandler(i, [
'containerHeight',
'contentHeight',
Expand All @@ -516,7 +522,8 @@ var dragThumb = function(i) {
'scrollbarY',
'scrollbarYHeight',
'scrollTop',
'y' ]);
'y',
'scrollbarYRail' ]);
};

function bindMouseScrollHandler(
Expand All @@ -531,6 +538,7 @@ function bindMouseScrollHandler(
var scrollbarYHeight = ref[5];
var scrollTop = ref[6];
var y = ref[7];
var scrollbarYRail = ref[8];

var element = i.element;

Expand All @@ -550,6 +558,7 @@ function bindMouseScrollHandler(

function mouseUpHandler() {
removeScrollingClass(i, y);
i[scrollbarYRail].classList.remove(cls.state.clicking);
i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
}

Expand All @@ -563,6 +572,8 @@ function bindMouseScrollHandler(
i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);

i[scrollbarYRail].classList.add(cls.state.clicking);

e.stopPropagation();
e.preventDefault();
});
Expand All @@ -575,7 +586,7 @@ var keyboard = function(i) {
var scrollbarFocused = function () { return matches(i.scrollbarX, ':focus') || matches(i.scrollbarY, ':focus'); };

function shouldPreventDefault(deltaX, deltaY) {
var scrollTop = element.scrollTop;
var scrollTop = Math.floor(element.scrollTop);
if (deltaX === 0) {
if (!i.scrollbarYActive) {
return false;
Expand Down Expand Up @@ -716,12 +727,13 @@ var wheel = function(i) {
var element = i.element;

function shouldPreventDefault(deltaX, deltaY) {
var roundedScrollTop = Math.floor(element.scrollTop);
var isTop = element.scrollTop === 0;
var isBottom =
element.scrollTop + element.offsetHeight === element.scrollHeight;
roundedScrollTop + element.offsetHeight === element.scrollHeight;
var isLeft = element.scrollLeft === 0;
var isRight =
element.scrollLeft + element.offsetWidth === element.offsetWidth;
element.scrollLeft + element.offsetWidth === element.scrollWidth;

var hitsBound;

Expand Down Expand Up @@ -797,7 +809,7 @@ var wheel = function(i) {
return true;
}
}
var maxScrollLeft = cursor.scrollLeft - cursor.clientWidth;
var maxScrollLeft = cursor.scrollWidth - cursor.clientWidth;
if (maxScrollLeft > 0) {
if (
!(cursor.scrollLeft === 0 && deltaX < 0) &&
Expand Down Expand Up @@ -873,7 +885,7 @@ var touch = function(i) {
var element = i.element;

function shouldPrevent(deltaX, deltaY) {
var scrollTop = element.scrollTop;
var scrollTop = Math.floor(element.scrollTop);
var scrollLeft = element.scrollLeft;
var magnitudeX = Math.abs(deltaX);
var magnitudeY = Math.abs(deltaY);
Expand Down Expand Up @@ -1087,7 +1099,7 @@ var defaultSettings = function () { return ({
suppressScrollY: false,
swipeEasing: true,
useBothWheelAxes: false,
wheelPropagation: false,
wheelPropagation: true,
wheelSpeed: 1,
}); };

Expand Down Expand Up @@ -1218,7 +1230,7 @@ var PerfectScrollbar = function PerfectScrollbar(element, userSettings) {

this.settings.handlers.forEach(function (handlerName) { return handlers[handlerName](this$1); });

this.lastScrollTop = element.scrollTop; // for onScroll only
this.lastScrollTop = Math.floor(element.scrollTop); // for onScroll only
this.lastScrollLeft = element.scrollLeft; // for onScroll only
this.event.bind(this.element, 'scroll', function (e) { return this$1.onScroll(e); });
updateGeometry(this);
Expand Down Expand Up @@ -1270,7 +1282,7 @@ PerfectScrollbar.prototype.onScroll = function onScroll (e) {
this.element.scrollLeft - this.lastScrollLeft
);

this.lastScrollTop = this.element.scrollTop;
this.lastScrollTop = Math.floor(this.element.scrollTop);
this.lastScrollLeft = this.element.scrollLeft;
};

Expand Down
Loading

0 comments on commit cb871a0

Please sign in to comment.