mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-01 13:03:08 +08:00
Summary: * Added snapToOffsets prop to ScrollView. Allows snapping at arbitrary points. * Fixed pagingEnabled not being overridden by snapToInterval on iOS. * Fixed Android *requiring* pagingEnabled to be defined alongside snapToInterval. * Added support for decelerationRate on Android. * Fixed snapping implementation. It was not calculating end position correctly at all (velocity is not a linear offset). * Resolves https://github.com/facebook/react-native/issues/20155 * Added support for new content being added during scroll (mirrors existing functionality in vertical ScrollView). * Added support for snapToInterval. * Resolves https://github.com/facebook/react-native/issues/19552 Reviewed By: yungsters Differential Revision: D9405703 fbshipit-source-id: b3c367b8079e6810794b0165dfdbcff4abff2eda
33 lines
665 B
JavaScript
33 lines
665 B
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const Platform = require('Platform');
|
|
|
|
function processDecelerationRate(
|
|
decelerationRate: number | 'normal' | 'fast',
|
|
): number {
|
|
if (decelerationRate === 'normal') {
|
|
return Platform.select({
|
|
ios: 0.998,
|
|
android: 0.985,
|
|
});
|
|
} else if (decelerationRate === 'fast') {
|
|
return Platform.select({
|
|
ios: 0.99,
|
|
android: 0.9,
|
|
});
|
|
}
|
|
return decelerationRate;
|
|
}
|
|
|
|
module.exports = processDecelerationRate;
|