mirror of
https://github.com/status-im/react-native.git
synced 2025-01-20 22:39:20 +00:00
0f7477f9f9
Summary: Expose a `decelerationNormalEnabled` flag on WebView, which, when enabled, will WebView's ScrollView's `decelerationRate` to `UIScrollViewDecelerationRateNormal`. This gives the WebView the same "momentum" style scrolling as other iOS views. This was discussed with ide in #5447. Please let me know if there's anything I'm missing, or anything else you'd like to see in this pull request. Closes https://github.com/facebook/react-native/pull/5527 Reviewed By: svcscm Differential Revision: D2870312 Pulled By: nicklockwood fb-gh-sync-id: 7dbfd06a349e3365a5df40c3bacf25a4fdb306cf
30 lines
1003 B
JavaScript
30 lines
1003 B
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule processDecelerationRate
|
|
*/
|
|
'use strict';
|
|
|
|
var ScrollViewConsts = require('UIManager').RCTScrollView.Constants;
|
|
|
|
function processDecelerationRate(decelerationRate) {
|
|
var ScrollViewDecelerationRateNormal = ScrollViewConsts && ScrollViewConsts.DecelerationRate.normal;
|
|
var ScrollViewDecelerationRateFast = ScrollViewConsts && ScrollViewConsts.DecelerationRate.fast;
|
|
|
|
if (typeof decelerationRate === 'string') {
|
|
if (decelerationRate === 'fast') {
|
|
return ScrollViewDecelerationRateFast;
|
|
} else if (decelerationRate === 'normal') {
|
|
return ScrollViewDecelerationRateNormal;
|
|
}
|
|
}
|
|
return decelerationRate;
|
|
}
|
|
|
|
module.exports = processDecelerationRate;
|