Skip to content
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
18 changes: 15 additions & 3 deletions modules/mixins/scroll-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export default (Component, customScroller) => {
const scroller = customScroller || defaultScroller;

class Link extends React.PureComponent {
element = null;
elementBounds = {
topBound: 0,
bottomBound: 0,
}

constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -75,9 +81,9 @@ export default (Component, customScroller) => {
}

let to = this.props.to;
let element = null;
let elemTopBound = 0;
let elemBottomBound = 0;
let element = this.element;
let elemTopBound = this.elementBounds.topBound;
let elemBottomBound = this.elementBounds.bottomBound;
let containerTop = 0;

if (scrollSpyContainer.getBoundingClientRect) {
Expand All @@ -92,6 +98,12 @@ export default (Component, customScroller) => {
let cords = element.getBoundingClientRect();
elemTopBound = (cords.top - containerTop + y);
elemBottomBound = elemTopBound + cords.height;

this.element = element
this.elementBounds = {
topBound: elemTopBound,
bottomBound: elemBottomBound
}
}

let offsetY = y - this.props.offset;
Expand Down