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 scrollOffset #225

Open
wants to merge 1 commit 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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ React.render(

> smooth - animate the scrolling

> offset - scroll additional px ( like padding )
> offset - element bound and scroll offset px ( like padding )

> scrollOffset - additional scroll offset px ( used only by scrollTo )

> duration - time of the scroll animation

Expand Down
4 changes: 4 additions & 0 deletions examples/basic/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
padding-left:10px;
}

#offset {
padding-top:155px;
}

.active {
color:red !important;
}
5 changes: 5 additions & 0 deletions examples/basic/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Section extends React.Component{
<li> <a onClick={() => scroll.scrollMore(1000, { delay : 1500 })}>Scroll 1000 More! ( delay ) </a></li>
<li><Link activeClass="active" className="test8" to="same" spy={true} smooth={true} duration={500}>Same target</Link></li>
<li><Link activeClass="active" className="test9" to="same" spy={true} smooth={true} duration={500}>Same target</Link></li>
<li><Link activeClass="active" className="test10" to="offset" spy={true} offset={100} scrollOffset={25}>Test offset</Link></li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -124,6 +125,10 @@ class Section extends React.Component{
Two links point to this
</Element>

<div id="offset" className="element">
Offset
</div>

<a onClick={this.scrollToTop}>To the top!</a>

</div>
Expand Down
3 changes: 2 additions & 1 deletion modules/mixins/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var protoTypes = {
spy: PropTypes.bool,
smooth: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
offset: PropTypes.number,
scrollOffset: PropTypes.number,
delay: PropTypes.number,
isDynamic: PropTypes.bool,
onClick: PropTypes.func,
Expand Down Expand Up @@ -206,7 +207,7 @@ var Helpers = {
}
};
_.propTypes = protoTypes;
_.defaultProps={offset: 0};
_.defaultProps={offset: 0, scrollOffset: 0};
return _;
},

Expand Down
2 changes: 1 addition & 1 deletion modules/mixins/scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
}

scrollOffset += (props.offset || 0);

scrollOffset += (props.scrollOffset || 0);

/*
* if animate is not provided just scroll into the view
Expand Down