Skip to content

Commit 585ea6c

Browse files
authored
Merge pull request #187 from brigade/body-with-overflow
Assume `window` as scrollableAncestor for <body>
2 parents a6c085e + f140765 commit 585ea6c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

spec/waypoint_spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,11 +1138,19 @@ describe('<Waypoint>', function() {
11381138
this.parentStyle.height = 'auto';
11391139
this.parentStyle.overflow = 'visible';
11401140

1141+
// This is only here to try and confuse the _findScrollableAncestor code.
1142+
document.body.style.overflow = 'auto';
1143+
11411144
// Make the spacers large enough to make the Waypoint render off-screen
11421145
this.topSpacerHeight = window.innerHeight + 1000;
11431146
this.bottomSpacerHeight = 1000;
11441147
});
11451148

1149+
afterEach(() => {
1150+
// Reset body style
1151+
document.body.style.overflow = '';
1152+
});
1153+
11461154
it('does not fire the onEnter handler on mount', () => {
11471155
this.subject();
11481156
expect(this.props.onEnter).not.toHaveBeenCalled();

src/waypoint.jsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,9 @@ export default class Waypoint extends React.Component {
121121
while (node.parentNode) {
122122
node = node.parentNode;
123123

124-
if (node === document) {
125-
// This particular node does not have a computed style.
126-
continue;
127-
}
128-
129-
if (node === document.documentElement) {
130-
// This particular node does not have a scroll bar, it uses the window.
131-
continue;
124+
if (node === document.body) {
125+
// We've reached all the way to the root node.
126+
return window;
132127
}
133128

134129
const style = window.getComputedStyle(node);

0 commit comments

Comments
 (0)