Skip to content
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: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ A boolean to determine whether the `translate3d` CSS property should be used for
positioning instead of the default `translate`. This can help performance on
mobile devices, but is supported by fewer browsers.

#### useStaticScrollParent (defaults to `false`)

Set to `true` if the scroll parent will never change. This is an opt-in optimization that will only search for the scroll parent (or call scrollParentGetter) once for the duration of the component's life.

## Methods

##### scrollTo(index)
Expand Down
9 changes: 7 additions & 2 deletions react-list.es6
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ module.exports = class ReactList extends Component {
threshold: PropTypes.number,
type: PropTypes.oneOf(['simple', 'variable', 'uniform']),
useStaticSize: PropTypes.bool,
useTranslate3d: PropTypes.bool
useTranslate3d: PropTypes.bool,
useStaticScrollParent: PropTypes.bool
};

static defaultProps = {
Expand All @@ -70,7 +71,8 @@ module.exports = class ReactList extends Component {
threshold: 100,
type: 'simple',
useStaticSize: false,
useTranslate3d: false
useTranslate3d: false,
useStaticScrollParent: false
};

constructor(props) {
Expand Down Expand Up @@ -257,6 +259,9 @@ module.exports = class ReactList extends Component {

updateScrollParent() {
const prev = this.scrollParent;
if (prev && this.props.useStaticScrollParent) {
return;
}
this.scrollParent = this.getScrollParent();
if (prev === this.scrollParent) return;
if (prev) {
Expand Down
9 changes: 7 additions & 2 deletions react-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@
key: 'updateScrollParent',
value: function updateScrollParent() {
var prev = this.scrollParent;
if (prev && this.props.useStaticScrollParent) {
return;
}
this.scrollParent = this.getScrollParent();
if (prev === this.scrollParent) return;
if (prev) {
Expand Down Expand Up @@ -660,7 +663,8 @@
threshold: _propTypes2.default.number,
type: _propTypes2.default.oneOf(['simple', 'variable', 'uniform']),
useStaticSize: _propTypes2.default.bool,
useTranslate3d: _propTypes2.default.bool
useTranslate3d: _propTypes2.default.bool,
useStaticScrollParent: _propTypes2.default.bool
}, _class.defaultProps = {
axis: 'y',
itemRenderer: function itemRenderer(index, key) {
Expand All @@ -683,6 +687,7 @@
threshold: 100,
type: 'simple',
useStaticSize: false,
useTranslate3d: false
useTranslate3d: false,
useStaticScrollParent: false
}, _temp);
});