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

[sticky-navigation] Remove bootstrap behaviour, make our own for affix #111

Merged
merged 1 commit into from
Jun 16, 2015
Merged
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
9 changes: 6 additions & 3 deletions common/sticky-navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ let StickyNavigation = {
return ({
titleSelector: '[data-menu]',
scrolledElementSelector: 'body',
hasBackToTop: true
hasBackToTop: true,
affixMargin: 80
});
},
/**
Expand All @@ -37,7 +38,8 @@ let StickyNavigation = {
scrolledElementSelector: type('string'),
triggerHeight: type('number'),
style: type('object'),
hasBackToTop: type('bool')
hasBackToTop: type('bool'),
affixMargin: type('number')
},
/**
* Component did mount, attach the scroll spy
Expand Down Expand Up @@ -96,6 +98,7 @@ let StickyNavigation = {
*/
_scrollSpy() {
let scrollPosition = document.querySelector(this.props.scrolledElementSelector).scrollTop;
this.setState({affixNav: this.props.affixMargin < scrollPosition});
if (this.state && this.state.titleList) {
this.state.titleList.forEach((title) => {
if (title.offsetTop <= scrollPosition && title.offsetTop + title.offsetHeight > scrollPosition) {
Expand Down Expand Up @@ -140,7 +143,7 @@ let StickyNavigation = {
*/
render() {
return (
<nav data-focus='sticky-navigation' className={this._getStyleClassName()} data-spy="affix" data-offset-top="0" data-offset-bottom="0">
<nav data-focus='sticky-navigation' className={this._getStyleClassName()} data-affix={this.state && this.state.affixNav ? 'true' : 'false'} ref='nav'>
{this._renderList()}
</nav>
)
Expand Down
6 changes: 5 additions & 1 deletion common/sticky-navigation/style/sticky-navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ $sticky-nav-active-color:#36b7b9;
float: left;
font-size: 13pt;

&.affix {
&[data-affix='true'] {
position: fixed;
top: 80px;
}
&[data-affix='false'] {

}

div {
padding: 5px 10px;
Expand Down