Skip to content

Commit

Permalink
Merge pull request #1 from rodrigoddalmeida/hide-scrollbar
Browse files Browse the repository at this point in the history
Good, thanks! :)
  • Loading branch information
buzinas committed Oct 7, 2015
2 parents 17824a0 + f430ba2 commit d93387b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
40 changes: 22 additions & 18 deletions simple-scrollbar.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
.ss-wrapper {
overflow : hidden;
height : 100%;
position : relative;
z-index : 1;
float: left;
overflow : hidden;
height : 100%;
position : relative;
z-index : 1;
float: left;
}

.ss-content {
height : 100%;
width : 100%;
padding : 0 32px 0 0;
position : relative;
right : -18px;
overflow : auto;
-moz-box-sizing : border-box;
box-sizing : border-box;
height : 100%;
width : 100%;
padding : 0 32px 0 0;
position : relative;
right : -18px;
overflow : auto;
-moz-box-sizing : border-box;
box-sizing : border-box;
}

.ss-scroll {
Expand All @@ -29,14 +29,18 @@
transition: opacity 0.25s linear;
}

.ss-hidden {
display: none;
}

.ss-container:hover .ss-scroll {
opacity: 1;
}

.ss-grabbed {
user-select: none;
-o-user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
-o-user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
}
12 changes: 9 additions & 3 deletions simple-scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,25 @@
this.scrollRatio = ownHeight / totalHeight;

raf(function() {
_this.bar.style.cssText = 'height:' + (ownHeight / totalHeight) * 100 + '%; top:' + (_this.el.scrollTop / totalHeight ) * 100 + '%;right:-' + (_this.target.clientWidth - _this.bar.clientWidth) + 'px;';
// Hide scrollbar if no scrolling is possible
if(_this.scrollRatio === 1) {
_this.bar.classList.add('ss-hidden')
} else {
_this.bar.classList.remove('ss-hidden')
_this.bar.style.cssText = 'height:' + (_this.scrollRatio) * 100 + '%; top:' + (_this.el.scrollTop / totalHeight ) * 100 + '%;right:-' + (_this.target.clientWidth - _this.bar.clientWidth) + 'px;';
}
});
}
}

function initAll() {
var nodes = d.querySelectorAll('*[ss-container]');

for (var i = 0; i < nodes.length; i++) {
initEl(nodes[i]);
}
}

d.addEventListener('DOMContentLoaded', initAll);
ss.initEl = initEl;
ss.initAll = initAll;
Expand Down
2 changes: 1 addition & 1 deletion simple-scrollbar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d93387b

Please sign in to comment.