Renamed throttleScrollCallbackMS to scrollEventThrottle
This commit is contained in:
parent
15eb5fde51
commit
961f301d65
|
@ -33,7 +33,7 @@ exports.examples = [
|
||||||
return (
|
return (
|
||||||
<ScrollView
|
<ScrollView
|
||||||
onScroll={() => { console.log('onScroll!'); }}
|
onScroll={() => { console.log('onScroll!'); }}
|
||||||
throttleScrollCallbackMS={200}
|
scrollEventThrottle={200}
|
||||||
contentInset={{top: -50}}
|
contentInset={{top: -50}}
|
||||||
style={styles.scrollView}>
|
style={styles.scrollView}>
|
||||||
{THUMBS.map(createThumbRow)}
|
{THUMBS.map(createThumbRow)}
|
||||||
|
|
|
@ -64,7 +64,7 @@ var ScrollView = React.createClass({
|
||||||
showsHorizontalScrollIndicator: PropTypes.bool,
|
showsHorizontalScrollIndicator: PropTypes.bool,
|
||||||
showsVerticalScrollIndicator: PropTypes.bool,
|
showsVerticalScrollIndicator: PropTypes.bool,
|
||||||
style: StyleSheetPropType(ViewStylePropTypes),
|
style: StyleSheetPropType(ViewStylePropTypes),
|
||||||
throttleScrollCallbackMS: PropTypes.number, // null
|
scrollEventThrottle: PropTypes.number, // null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When true, the scroll view bounces horizontally when it reaches the end
|
* When true, the scroll view bounces horizontally when it reaches the end
|
||||||
|
@ -211,12 +211,12 @@ var ScrollView = React.createClass({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
if (this.props.onScroll && !this.props.throttleScrollCallbackMS) {
|
if (this.props.onScroll && !this.props.scrollEventThrottle) {
|
||||||
var onScroll = this.props.onScroll;
|
var onScroll = this.props.onScroll;
|
||||||
this.props.onScroll = function() {
|
this.props.onScroll = function() {
|
||||||
console.log(
|
console.log(
|
||||||
'You specified `onScroll` on a <ScrollView> but not ' +
|
'You specified `onScroll` on a <ScrollView> but not ' +
|
||||||
'`throttleScrollCallbackMS`. You will only receive one event. ' +
|
'`scrollEventThrottle`. You will only receive one event. ' +
|
||||||
'Using `16` you get all the events but be aware that it may ' +
|
'Using `16` you get all the events but be aware that it may ' +
|
||||||
'cause frame drops, use a bigger number if you don\'t need as ' +
|
'cause frame drops, use a bigger number if you don\'t need as ' +
|
||||||
'much precision.'
|
'much precision.'
|
||||||
|
@ -325,7 +325,7 @@ var validAttributes = {
|
||||||
showsHorizontalScrollIndicator: true,
|
showsHorizontalScrollIndicator: true,
|
||||||
showsVerticalScrollIndicator: true,
|
showsVerticalScrollIndicator: true,
|
||||||
stickyHeaderIndices: {diff: deepDiffer},
|
stickyHeaderIndices: {diff: deepDiffer},
|
||||||
throttleScrollCallbackMS: true,
|
scrollEventThrottle: true,
|
||||||
zoomScale: true,
|
zoomScale: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -325,8 +325,8 @@ var ListView = React.createClass({
|
||||||
stickyHeaderIndices: sectionHeaderIndices,
|
stickyHeaderIndices: sectionHeaderIndices,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (!props.throttleScrollCallbackMS) {
|
if (!props.scrollEventThrottle) {
|
||||||
props.throttleScrollCallbackMS = DEFAULT_SCROLL_CALLBACK_THROTTLE;
|
props.scrollEventThrottle = DEFAULT_SCROLL_CALLBACK_THROTTLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
||||||
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
||||||
@property (nonatomic, assign) NSUInteger throttleScrollCallbackMS;
|
@property (nonatomic, assign) NSTimeInterval scrollEventThrottle;
|
||||||
@property (nonatomic, assign) BOOL centerContent;
|
@property (nonatomic, assign) BOOL centerContent;
|
||||||
@property (nonatomic, copy) NSArray *stickyHeaderIndices;
|
@property (nonatomic, copy) NSArray *stickyHeaderIndices;
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ CGFloat const ZINDEX_STICKY_HEADER = 50;
|
||||||
_contentInset = UIEdgeInsetsZero;
|
_contentInset = UIEdgeInsetsZero;
|
||||||
_contentSize = CGSizeZero;
|
_contentSize = CGSizeZero;
|
||||||
|
|
||||||
_throttleScrollCallbackMS = 0;
|
_scrollEventThrottle = 0.0;
|
||||||
_lastScrollDispatchTime = CACurrentMediaTime();
|
_lastScrollDispatchTime = CACurrentMediaTime();
|
||||||
_cachedChildFrames = [[NSMutableArray alloc] init];
|
_cachedChildFrames = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
|
@ -393,16 +393,15 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidZoom, RCTScrollEventTypeMove)
|
||||||
[self updateClippedSubviews];
|
[self updateClippedSubviews];
|
||||||
|
|
||||||
NSTimeInterval now = CACurrentMediaTime();
|
NSTimeInterval now = CACurrentMediaTime();
|
||||||
NSTimeInterval throttleScrollCallbackSeconds = _throttleScrollCallbackMS / 1000.0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: this logic looks wrong, and it may be because it is. Currently, if _throttleScrollCallbackMS
|
* TODO: this logic looks wrong, and it may be because it is. Currently, if _scrollEventThrottle
|
||||||
* is set to zero (the default), the "didScroll" event is only sent once per scroll, instead of repeatedly
|
* is set to zero (the default), the "didScroll" event is only sent once per scroll, instead of repeatedly
|
||||||
* while scrolling as expected. However, if you "fix" that bug, ScrollView will generate repeated
|
* while scrolling as expected. However, if you "fix" that bug, ScrollView will generate repeated
|
||||||
* warnings, and behave strangely (ListView works fine however), so don't fix it unless you fix that too!
|
* warnings, and behave strangely (ListView works fine however), so don't fix it unless you fix that too!
|
||||||
*/
|
*/
|
||||||
if (_allowNextScrollNoMatterWhat ||
|
if (_allowNextScrollNoMatterWhat ||
|
||||||
(_throttleScrollCallbackMS != 0 && throttleScrollCallbackSeconds < (now - _lastScrollDispatchTime))) {
|
(_scrollEventThrottle > 0 && _scrollEventThrottle < (now - _lastScrollDispatchTime))) {
|
||||||
|
|
||||||
// Calculate changed frames
|
// Calculate changed frames
|
||||||
NSMutableArray *updatedChildFrames = [[NSMutableArray alloc] init];
|
NSMutableArray *updatedChildFrames = [[NSMutableArray alloc] init];
|
||||||
|
|
|
@ -39,12 +39,14 @@ RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(scrollsToTop, BOOL)
|
RCT_EXPORT_VIEW_PROPERTY(scrollsToTop, BOOL)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL)
|
RCT_EXPORT_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL)
|
RCT_EXPORT_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(stickyHeaderIndices, NSNumberArray);
|
RCT_EXPORT_VIEW_PROPERTY(stickyHeaderIndices, NSNumberArray)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(throttleScrollCallbackMS, double);
|
RCT_EXPORT_VIEW_PROPERTY(scrollEventThrottle, NSTimeInterval)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(zoomScale, CGFloat);
|
RCT_EXPORT_VIEW_PROPERTY(zoomScale, CGFloat)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets);
|
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(scrollIndicatorInsets, UIEdgeInsets);
|
RCT_EXPORT_VIEW_PROPERTY(scrollIndicatorInsets, UIEdgeInsets)
|
||||||
RCT_REMAP_VIEW_PROPERTY(contentOffset, scrollView.contentOffset, CGPoint);
|
RCT_REMAP_VIEW_PROPERTY(contentOffset, scrollView.contentOffset, CGPoint)
|
||||||
|
|
||||||
|
RCT_DEPRECATED_VIEW_PROPERTY(throttleScrollCallbackMS, scrollEventThrottle)
|
||||||
|
|
||||||
- (NSDictionary *)constantsToExport
|
- (NSDictionary *)constantsToExport
|
||||||
{
|
{
|
||||||
|
|
|
@ -153,4 +153,19 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v
|
||||||
#define RCT_IGNORE_SHADOW_PROPERTY(name) \
|
#define RCT_IGNORE_SHADOW_PROPERTY(name) \
|
||||||
- (void)set_##name:(id)value forShadowView:(id)view withDefaultView:(id)defaultView {}
|
- (void)set_##name:(id)value forShadowView:(id)view withDefaultView:(id)defaultView {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for when view property names change. Will log an error when used.
|
||||||
|
*/
|
||||||
|
#define RCT_DEPRECATED_VIEW_PROPERTY(oldName, newName) \
|
||||||
|
- (void)set_##oldName:(id)json forView:(id)view withDefaultView:(id)defaultView { \
|
||||||
|
RCTLogError(@"Property '%s' has been replaced by '%s'.", #oldName, #newName); \
|
||||||
|
[self set_##newName:json forView:view withDefaultView:defaultView]; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RCT_DEPRECATED_SHADOW_PROPERTY(oldName, newName) \
|
||||||
|
- (void)set_##oldName:(id)json forShadowView:(id)view withDefaultView:(id)defaultView { \
|
||||||
|
RCTLogError(@"Property '%s' has been replaced by '%s'.", #oldName, #newName); \
|
||||||
|
[self set_##newName:json forView:view withDefaultView:defaultView]; \
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue