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

Adds the new option 'heightIgnoreClass' to manage more complex layout… #288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions jquery.slimscroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
// height in pixels of the visible scroll area
height : '250px',

// class to ignore element between the current scroller and parent (works only if height is 'auto')
heightIgnoreClass: 'listScrollIgnore',

// width in pixels of the scrollbar and rail
size : '7px',

Expand Down Expand Up @@ -113,6 +116,9 @@
me.parent().css('height', 'auto');
me.css('height', 'auto');
var height = me.parent().parent().height();
if ('heightIgnoreClass' in options & options.heightIgnoreClass !== '') {
height = height - calculateIgnoreHeight(options.heightIgnoreClass);
}
me.parent().css('height', height);
me.css('height', height);
} else if ('height' in options) {
Expand Down Expand Up @@ -156,6 +162,12 @@

// optionally set height to the parent's height
o.height = (o.height == 'auto') ? me.parent().height() : o.height;
if (options.height == 'auto' && 'heightIgnoreClass' in o & o.heightIgnoreClass !== '') {
// NOTE: in above if conditions is correct to use 'options.height' instead of 'o.height'
// because I want to check the original value (because heightIgnoreClass is active only
// if height == 'auto')
o.height = o.height - calculateIgnoreHeight(o.heightIgnoreClass);
}

// wrap content
var wrapper = $(divS)
Expand Down Expand Up @@ -460,6 +472,15 @@
}
}

// returns the grand total of heights to ignore
function calculateIgnoreHeight(ignoreClass) {
var outerHeight = 0;
$('.'+ignoreClass).each(function () {
outerHeight += $(this).outerHeight();
});
return outerHeight;
}

});

// maintain chainability
Expand Down