From b78efb2b5edbe89ddbb25708c77e352db647ffe4 Mon Sep 17 00:00:00 2001 From: Kristian Gerardsson Date: Tue, 5 May 2020 20:55:46 +0800 Subject: [PATCH] Adding useAnimation prop --- src/AlphabetSectionList.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/AlphabetSectionList.js b/src/AlphabetSectionList.js index df1b3bd..b14eef0 100644 --- a/src/AlphabetSectionList.js +++ b/src/AlphabetSectionList.js @@ -52,7 +52,7 @@ export default class AlphabetSectionList extends Component { } const index = keys.indexOf(section); - this.refs.listview.scrollToLocation({ sectionIndex: index, itemIndex: 0, animated: true }); + this.refs.listview.scrollToLocation({ sectionIndex: index, itemIndex: 0, animated: this.props.useAnimation }); this.props.onScrollToSection && this.props.onScrollToSection(section); } @@ -176,6 +176,10 @@ const stylesheetProp = PropTypes.oneOfType([ PropTypes.object, ]); +AlphabetSectionList.defaultProps = { + useAnimation: true +} + AlphabetSectionList.propTypes = { /** * The data to render in the listview @@ -268,4 +272,9 @@ AlphabetSectionList.propTypes = { * Default section header text style */ sectionHeaderTextStyle: stylesheetProp, + + /** + * If we should animate when we change section + */ + useAnimation: PropTypes.bool, };