diff --git a/README.md b/README.md index 3405900..aa4a791 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#Slim-scroll (_JavaScript Scroll Library) +#Slim-scroll (_JavaScript Scroll Library_) Slim scroll is a replacement of default scrollbar provided by browsers on Windows. This library lets you design the scroll-bar by using simple css properties. It is created using javascript and css. This will change the style only if the default scrollbar looks ugly. @@ -12,7 +12,7 @@ Slim scroll is a replacement of default scrollbar provided by browsers on Window - Works for Windows. (_Need help to check on other Operating Systems_) - Easier to color the custom scrollbar using CSS. - Can animate easily (_check below properties for support_). -- Re-evaluates when the window is resized, vertically. +- Re-evaluates when the container is fluid, vertically. ###How to use: - To make it work, include `slimscroll.js` in `head` tag. diff --git a/slimscroll.js b/slimscroll.js index 6fc4fbd..2f64bec 100644 --- a/slimscroll.js +++ b/slimscroll.js @@ -21,6 +21,9 @@ var slimScroll = function(C, payload){ return; } } + + // hide the scrollbar temporarily to take the calculations correctly + i[w].setAttribute("style", "overflow: hidden !important"); var q = i.E; i.h = i[S].offsetHeight; i.sH = i[w].scrollHeight; @@ -224,6 +227,8 @@ var slimScroll = function(C, payload){ setAttr(i[s], 'data-scrollbar', '1'); assignValues(); + // Show the default scrollbar to get the scrollbar width + i[w].style.overflow = ""; var scrollBarWidth = i[w].offsetWidth - i[w].clientWidth; // Stretching the inner container so that the default scrollbar is completely invisible if(Math.abs(scrollBarWidth) < 5){