Skip to content

Commit

Permalink
upgrade perfect-scrollbar
Browse files Browse the repository at this point in the history
- update CDN url
- simplify CSS import path
- update class names
- fix references to utility functions in Tabs component
  • Loading branch information
axelboc committed May 12, 2017
1 parent 97611a6 commit e93a401
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
7 changes: 4 additions & 3 deletions assets/components/tabs/_tabs.css
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,14 @@
z-index: 1;
}

.ps-scrollbar-x-rail {
.ps__scrollbar-x-rail {
z-index: 5;
}

/* show scrollbar when focused */
.ps-focus .ps-scrollbar-x-rail {
opacity: 1;
.ps--focus {
.ps__scrollbar-x-rail { opacity: 1; }
.ps__scrollbar-x { outline-offset: 1px; }
}

/* left/right arrows when screen size is too small to fit all the tabs */
Expand Down
2 changes: 1 addition & 1 deletion assets/components/tabs/index.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@import 'perfect-scrollbar/dist/css/perfect-scrollbar';
@import 'perfect-scrollbar';
@import '_tabs';
14 changes: 7 additions & 7 deletions assets/components/tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Tabs.prototype.handleResize = function() {
if (!this.props.isLoadingPs) {
// Load the 'perfect-scrollbar' library then setup the overflow behaviour
this.props.isLoadingPs = true;
window.loadScript('https://cdnjs.cloudflare.com/ajax/libs/jquery.perfect-scrollbar/0.6.10/js/min/perfect-scrollbar.min.js')
utils.loadScript('https://cdnjs.cloudflare.com/ajax/libs/jquery.perfect-scrollbar/0.7.0/js/perfect-scrollbar.min.js')
.then(this.setupOverflow.bind(this));
}
} else {
Expand All @@ -142,7 +142,7 @@ Tabs.prototype.handleResize = function() {
}
} else if (isOverflowing && this.props.isOverflowSetup) {
// If initialised and still overflowing, only update the horizontal scrollbar and scroll to the selected tab
Ps.update(this.props.inner);
window.Ps.update(this.props.inner);
this.scrollToTab(this.el.querySelector('[data-current]'), true);
}
};
Expand Down Expand Up @@ -202,7 +202,7 @@ Tabs.prototype.activateOverflow = function(smooth) {
this.props.navParent.classList.add('overflow');

// Initialise the scrollbar
Ps.initialize(this.props.inner, {
window.Ps.initialize(this.props.inner, {
useBothWheelAxes: true,
wheelPropagation: true
});
Expand All @@ -216,7 +216,7 @@ Tabs.prototype.activateOverflow = function(smooth) {
*/
Tabs.prototype.destroyOverflow = function() {
this.props.navParent.classList.remove('overflow');
Ps.destroy(this.props.inner);
window.Ps.destroy(this.props.inner);
};

/**
Expand Down Expand Up @@ -395,20 +395,20 @@ Tabs.prototype.scrollTabs = function(to, smooth) {
this.animateTabsScroll(0, start, change, duration, increment);
} else {
this.props.inner.scrollLeft = to;
Ps.update(this.props.inner);
window.Ps.update(this.props.inner);
}
};

Tabs.prototype.animateTabsScroll = function(curr, start, change, duration, increment) {
curr += increment;
this.props.inner.scrollLeft = Math.easeInOutQuad(curr, start, change, duration);
this.props.inner.scrollLeft = utils.easeInOutQuad(curr, start, change, duration);

if (curr < duration) {
setTimeout(this.animateTabsScroll.bind(this, curr, start, change, duration, increment), increment);
} else {
// If the tabs are still overflowing when the scrolling ends, update the scrollbars
if (this.props.isOverflowing) {
Ps.update(this.props.inner);
window.Ps.update(this.props.inner);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"just-debounce": "^1.0.0",
"locale-compare-polyfill": "~0.0.2",
"normalize.css": "^5.0.0",
"perfect-scrollbar": "^0.6.10",
"perfect-scrollbar": "^0.7.0",
"photoswipe": "^4.1.1",
"string-hash": "^1.1.3",
"webfontloader": "~1.6.3"
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2595,9 +2595,9 @@ pbkdf2@^3.0.3:
safe-buffer "^5.0.1"
sha.js "^2.4.8"

perfect-scrollbar@^0.6.10:
version "0.6.16"
resolved "https://registry.yarnpkg.com/perfect-scrollbar/-/perfect-scrollbar-0.6.16.tgz#b1d61a5245cf3962bb9a8407a3fc669d923212fc"
perfect-scrollbar@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/perfect-scrollbar/-/perfect-scrollbar-0.7.0.tgz#85280682cb61ee90f8c0786c9ca5b704471ece1a"

performance-now@^0.2.0:
version "0.2.0"
Expand Down

0 comments on commit e93a401

Please sign in to comment.