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

Optional fixed width coloumns #47

Open
wants to merge 3 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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ Options
* this is the JQuery selector of the element that your header is bound to. Sticky header will follow the position of that element and keep the header on top of that element as it scrolls off the page.
* scroll-stop
* this is how many pixels from the top of the page your elment will stop scrolling at, just in case you have a header on the top of your page.
* content-offset
* This adds x amount of pixels to the $(scroll-body).offset().top when calculating when the sticky header should stick etc.
* scrollable-container
* If you have a scrollable element such as a div, rather than the web page body scrolling, you'll need to specify that element id here.
* fsm-z-index
* Allows you to set the z-index per sticky header, especially when you have sub table headers
* fsm-is-fixed
* The default is fluid width and calculates thead th widths based on a 80% window width, fixed will just use the column offsetWidth.

Browser Support
--------

We support the current versions of Chrome, Firefox, Safari, Microsoft Edge and Internet Explorer 10+.
We support the current versions of Chrome, Firefox, Safari, Microsoft Edge and Internet Explorer 10+.
13 changes: 8 additions & 5 deletions src/fsm-sticky-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
scrollStop: '=',
scrollableContainer: '=',
contentOffset: '=',
fsmZIndex: '='
fsmZIndex: '=',
fsmIsFixed: '='
},
link: function(scope, element, attributes, control){
var content,
Expand All @@ -36,10 +37,12 @@
var clonedColumns = clonedHeader.find('th');
header.find('th').each(function (index, column) {
var clonedColumn = $(clonedColumns[index]);
//clonedColumn.css( 'width', column.offsetWidth + 'px'); fixed thead width
// fluid thead / table
var finalWidthSet = column.offsetWidth / ($(window).innerWidth()-20)*100; // $(window) can be replace with a custom wrapper / container
clonedColumn.css('width',finalWidthSet + '%');
if (scope.fsmIsFixed) {
clonedColumn.css( 'width', column.offsetWidth + 'px');
} else {
var finalWidthSet = column.offsetWidth / ($(window).innerWidth()-20)*100; // $(window) can be replace with a custom wrapper / container
clonedColumn.css('width',finalWidthSet + '%');
}
});
}
};
Expand Down