Skip to content

Commit

Permalink
FIX: float precision error in IE11
Browse files Browse the repository at this point in the history
  • Loading branch information
BorjaArias committed Oct 12, 2018
1 parent f2254e6 commit b0197cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion UNRELEASED.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased

__Nothing Yet!__
**Changed:**

- bpk-component-infinite-scroll:
- Changed IntersectionObserver Threshold from 1 to 0.99.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('withInfiniteScroll', () => {
beforeEach(() => {
global.IntersectionObserver = class {
constructor(callback) {
intersect = async () => callback([{ intersectionRatio: 1 }]);
intersect = async () => callback([{ isIntersecting: true }]);
}
observe() {} // eslint-disable-line
unobserve() {} // eslint-disable-line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const withInfiniteScroll = (

this.props.dataSource.onDataChange(this.updateData);
this.observer = new IntersectionObserver(this.handleIntersection, {
threshold: 1,
threshold: 0.99, // using 0.99 instead of 1 to avoid problems with float precision in IE11
});
}

Expand Down Expand Up @@ -194,7 +194,7 @@ const withInfiniteScroll = (
handleIntersection = (entries: Array<IntersectionObserverEntry>) => {
const { onScroll } = this.props;
const entry = entries[0];
if (entry.intersectionRatio >= 1) {
if (entry.isIntersecting) {
if (this.sentinel) {
this.observer.unobserve(this.sentinel);
}
Expand Down

0 comments on commit b0197cb

Please sign in to comment.