Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add offset for slimscroll position #306

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-slimscroll",
"version": "1.3.8",
"version": "1.4.0",
"description": "slimScroll is a small jQuery plugin that transforms any div into a scrollable area. slimScroll doesn't occupy any visual space as it only appears on a user initiated mouse-over.",
"keywords": [
"scrollbar",
Expand Down
17 changes: 10 additions & 7 deletions jquery.slimscroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Version: 1.3.8
* Version: 1.4.0
*
*/
(function($) {
Expand Down Expand Up @@ -76,7 +76,10 @@
borderRadius: '7px',

// sets border radius of the rail
railBorderRadius : '7px'
railBorderRadius : '7px',

// sets offset of the scrollbar
offset: 0
};

var o = $.extend(defaults, options);
Expand Down Expand Up @@ -300,7 +303,7 @@
if (o.start === 'bottom')
{
// scroll content to bottom
bar.css({ top: me.outerHeight() - bar.outerHeight() });
bar.css({ top: me.outerHeight() - (bar.outerHeight() + o.offset) });
scrollContent(0, true);
}
else if (o.start !== 'top')
Expand Down Expand Up @@ -341,12 +344,12 @@
{
releaseScroll = false;
var delta = y;
var maxTop = me.outerHeight() - bar.outerHeight();
var maxTop = me.outerHeight() - (bar.outerHeight() + o.offset);

if (isWheel)
{
// move bar with mouse wheel
delta = parseInt(bar.css('top')) + y * parseInt(o.wheelStep) / 100 * bar.outerHeight();
delta = parseInt(bar.css('top')) + y * parseInt(o.wheelStep) / 100 * (bar.outerHeight() + o.offset);

// move bar, make sure it doesn't go out
delta = Math.min(Math.max(delta, 0), maxTop);
Expand All @@ -362,7 +365,7 @@
}

// calculate actual scroll amount
percentScroll = parseInt(bar.css('top')) / (me.outerHeight() - bar.outerHeight());
percentScroll = parseInt(bar.css('top')) / (me.outerHeight() - (bar.outerHeight() + o.offset));
delta = percentScroll * (me[0].scrollHeight - me.outerHeight());

if (isJump)
Expand Down Expand Up @@ -403,7 +406,7 @@
{
// calculate scrollbar height and make sure it is not too small
barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight);
bar.css({ height: barHeight + 'px' });
bar.css({ height: (barHeight - o.offset) + 'px' });

// hide scrollbar if content is not long enough
var display = barHeight == me.outerHeight() ? 'none' : 'block';
Expand Down
12 changes: 2 additions & 10 deletions jquery.slimscroll.min.js

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "jquery-slimscroll",
"main" : "jquery.slimscroll.js",
"version" : "1.3.8",
"version" : "1.4.0",
"title" : "jQuery slimScroll scrollbar",
"description" : "slimScroll is a small jQuery plugin that transforms any div into a scrollable area. slimScroll doesn't occupy any visual space as it only appears on a user initiated mouse-over.",
"keywords" : ["scrollbar", "scroll", "slimscroll", "scrollable", "scrolling", "scroller", "ui", "jquery-plugin", "ecosystem:jquery"],
Expand Down Expand Up @@ -29,4 +29,4 @@
"url": "http://www.opensource.org/licenses/gpl-license.php"
}
]
}
}