Skip to content

Commit d00514c

Browse files
authored
Add near-end threshold (#16)
1 parent ab51d13 commit d00514c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88
### Changed
9-
- `Composer`: fix [#13](https://github.com/compulim/react-scroll-to-bottom/pull/13), user scrolling in Firefox may have the scroll position locked occasionally, in PR [#12](https://github.com/compulim/react-scroll-to-bottom/pull/12)
10-
- `SpineTo`: fix [#10](https://github.com/compulim/react-scroll-to-bottom/pull/10) set stopping threshold from `0.5` to `1.5`, in PR [#14](https://github.com/compulim/react-scroll-to-bottom/pull/14)
9+
- `Composer`: fix [#13](https://github.com/compulim/react-scroll-to-bottom/issue/13), user scrolling in Firefox may have the scroll position locked occasionally, in PR [#12](https://github.com/compulim/react-scroll-to-bottom/pull/12)
10+
- `SpineTo`: fix [#10](https://github.com/compulim/react-scroll-to-bottom/issue/10), set stopping threshold from `0.5` to `1.5`, in PR [#14](https://github.com/compulim/react-scroll-to-bottom/pull/14)
11+
- `Composer`: fix [#15](https://github.com/compulim/react-scroll-to-bottom/issue/15), set near-end threshold from `0` to (less than) `1`, in PR [#16](https://github.com/compulim/react-scroll-to-bottom/pull/16)
1112

1213
## [1.3.0] - 2019-01-21
1314
### Changed

packages/component/src/ScrollToBottom/Composer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import memoize from 'memoize-one';
21
import PropTypes from 'prop-types';
32
import React from 'react';
43
import updateIn from 'simple-update-in';
@@ -10,6 +9,7 @@ import SpineTo from '../SpineTo';
109
import StateContext from './StateContext';
1110

1211
const MIN_CHECK_INTERVAL = 17; // 1 frame
12+
const NEAR_END_THRESHOLD = 1;
1313
const SCROLL_DECISION_DURATION = 34; // 2 frames
1414

1515
function setImmediateInterval(fn, ms) {
@@ -19,8 +19,8 @@ function setImmediateInterval(fn, ms) {
1919
}
2020

2121
function computeViewState({ stateContext: { mode }, target: { offsetHeight, scrollHeight, scrollTop } }) {
22-
const atBottom = scrollHeight - scrollTop - offsetHeight <= 0;
23-
const atTop = scrollTop <= 0;
22+
const atBottom = scrollHeight - scrollTop - offsetHeight < NEAR_END_THRESHOLD;
23+
const atTop = scrollTop < NEAR_END_THRESHOLD;
2424
const atEnd = mode === 'top' ? atTop : atBottom;
2525

2626
return {

0 commit comments

Comments
 (0)