mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Updated docs for next
This commit is contained in:
@@ -16,29 +16,26 @@ just when they are about to appear, and removes items that scroll way off
|
||||
screen to save memory and processing time.</p><p><code>FlatList</code> is also handy if you want to render separators between your items,
|
||||
multiple columns, infinite scroll loading, or any number of other features it
|
||||
supports out of the box.</p></div><h3><a class="anchor" name="props"></a>Props <a class="hash-link" href="docs/scrollview.html#props">#</a></h3><div class="props"><div class="prop"><h4 class="propTitle"><a class="anchor" name="viewproptypes"></a><a href="docs/viewproptypes.html#props">ViewPropTypes props...</a> <a class="hash-link" href="docs/scrollview.html#viewproptypes">#</a></h4></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="contentcontainerstyle"></a>contentContainerStyle?: <span class="propType">StyleSheetPropType(ViewStylePropTypes)</span> <a class="hash-link" href="docs/scrollview.html#contentcontainerstyle">#</a></h4><div><p>These styles will be applied to the scroll view content container which
|
||||
wraps all of the child views. Example:</p><p> return (
|
||||
<ScrollView contentContainerStyle={styles.contentContainer}>
|
||||
</ScrollView>
|
||||
);
|
||||
...
|
||||
const styles = StyleSheet.create({
|
||||
contentContainer: {
|
||||
paddingVertical: 20
|
||||
}
|
||||
});</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="horizontal"></a>horizontal?: <span class="propType">PropTypes.bool</span> <a class="hash-link" href="docs/scrollview.html#horizontal">#</a></h4><div><p>When true, the scroll view's children are arranged horizontally in a row
|
||||
wraps all of the child views. Example:</p><div class="prism language-javascript"><span class="token keyword">return</span> <span class="token punctuation">(</span>
|
||||
<ScrollView contentContainerStyle<span class="token operator">=</span><span class="token punctuation">{</span>styles<span class="token punctuation">.</span>contentContainer<span class="token punctuation">}</span><span class="token operator">></span>
|
||||
<<span class="token operator">/</span>ScrollView<span class="token operator">></span>
|
||||
<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||||
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
|
||||
const styles <span class="token operator">=</span> StyleSheet<span class="token punctuation">.</span><span class="token function">create<span class="token punctuation">(</span></span><span class="token punctuation">{</span>
|
||||
contentContainer<span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
paddingVertical<span class="token punctuation">:</span> <span class="token number">20</span>
|
||||
<span class="token punctuation">}</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></div></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="horizontal"></a>horizontal?: <span class="propType">PropTypes.bool</span> <a class="hash-link" href="docs/scrollview.html#horizontal">#</a></h4><div><p>When true, the scroll view's children are arranged horizontally in a row
|
||||
instead of vertically in a column. The default value is false.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="keyboarddismissmode"></a>keyboardDismissMode?: <span class="propType">PropTypes.oneOf([
|
||||
'none', // default
|
||||
'interactive',
|
||||
'on-drag',
|
||||
])</span> <a class="hash-link" href="docs/scrollview.html#keyboarddismissmode">#</a></h4><div><p>Determines whether the keyboard gets dismissed in response to a drag.
|
||||
- 'none' (the default), drags do not dismiss the keyboard.
|
||||
- 'on-drag', the keyboard is dismissed when a drag begins.
|
||||
- 'interactive', the keyboard is dismissed interactively with the drag and moves in
|
||||
synchrony with the touch; dragging upwards cancels the dismissal.
|
||||
On android this is not supported and it will have the same behavior as 'none'.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="keyboardshouldpersisttaps"></a>keyboardShouldPersistTaps?: <span class="propType">PropTypes.oneOf(['always', 'never', 'handled', false, true])</span> <a class="hash-link" href="docs/scrollview.html#keyboardshouldpersisttaps">#</a></h4><div><p>Determines when the keyboard should stay visible after a tap.</p><ul><li>'never' (the default), tapping outside of the focused text input when the keyboard
|
||||
is up dismisses the keyboard. When this happens, children won't receive the tap.</li><li>'always', the keyboard will not dismiss automatically, and the scroll view will not
|
||||
catch taps, but children of the scroll view can catch taps.</li><li>'handled', the keyboard will not dismiss automatically when the tap was handled by
|
||||
a children, (or captured by an ancestor).</li><li>false, deprecated, use 'never' instead</li><li>true, deprecated, use 'always' instead</li></ul></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="oncontentsizechange"></a>onContentSizeChange?: <span class="propType">PropTypes.func</span> <a class="hash-link" href="docs/scrollview.html#oncontentsizechange">#</a></h4><div><p>Called when scrollable content view of the ScrollView changes.</p><p>Handler function is passed the content width and content height as parameters:
|
||||
])</span> <a class="hash-link" href="docs/scrollview.html#keyboarddismissmode">#</a></h4><div><p>Determines whether the keyboard gets dismissed in response to a drag.</p><ul><li><code>'none'</code> (the default), drags do not dismiss the keyboard.</li><li><code>'on-drag'</code>, the keyboard is dismissed when a drag begins.</li><li><code>'interactive'</code>, the keyboard is dismissed interactively with the drag and moves in
|
||||
synchrony with the touch; dragging upwards cancels the dismissal.
|
||||
On android this is not supported and it will have the same behavior as 'none'.</li></ul></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="keyboardshouldpersisttaps"></a>keyboardShouldPersistTaps?: <span class="propType">PropTypes.oneOf(['always', 'never', 'handled', false, true])</span> <a class="hash-link" href="docs/scrollview.html#keyboardshouldpersisttaps">#</a></h4><div><p>Determines when the keyboard should stay visible after a tap.</p><ul><li><code>'never'</code> (the default), tapping outside of the focused text input when the keyboard
|
||||
is up dismisses the keyboard. When this happens, children won't receive the tap.</li><li><code>'always'</code>, the keyboard will not dismiss automatically, and the scroll view will not
|
||||
catch taps, but children of the scroll view can catch taps.</li><li><code>'handled'</code>, the keyboard will not dismiss automatically when the tap was handled by
|
||||
a children, (or captured by an ancestor).</li><li><code>false</code>, deprecated, use 'never' instead</li><li><code>true</code>, deprecated, use 'always' instead</li></ul></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="oncontentsizechange"></a>onContentSizeChange?: <span class="propType">PropTypes.func</span> <a class="hash-link" href="docs/scrollview.html#oncontentsizechange">#</a></h4><div><p>Called when scrollable content view of the ScrollView changes.</p><p>Handler function is passed the content width and content height as parameters:
|
||||
<code>(contentWidth, contentHeight)</code></p><p>It's implemented using onLayout handler attached to the content container
|
||||
which this ScrollView renders.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="onscroll"></a>onScroll?: <span class="propType">PropTypes.func</span> <a class="hash-link" href="docs/scrollview.html#onscroll">#</a></h4><div><p>Fires at most once per frame during scrolling. The frequency of the
|
||||
events can be controlled using the <code>scrollEventThrottle</code> prop.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="pagingenabled"></a>pagingEnabled?: <span class="propType">PropTypes.bool</span> <a class="hash-link" href="docs/scrollview.html#pagingenabled">#</a></h4><div><p>When true, the scroll view stops on multiples of the scroll view's size
|
||||
@@ -93,17 +90,12 @@ The default value is <code>{x: 0, y: 0}</code>.</p></div></div><div class="prop"
|
||||
decelerates after the user lifts their finger. You may also use string
|
||||
shortcuts <code>"normal"</code> and <code>"fast"</code> which match the underlying iOS settings
|
||||
for <code>UIScrollViewDecelerationRateNormal</code> and
|
||||
<code>UIScrollViewDecelerationRateFast</code> respectively.
|
||||
- normal: 0.998 (the default)
|
||||
- fast: 0.99</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="directionallockenabled"></a><span class="platform">ios</span>directionalLockEnabled?: <span class="propType">PropTypes.bool</span> <a class="hash-link" href="docs/scrollview.html#directionallockenabled">#</a></h4><div><p>When true, the ScrollView will try to lock to only vertical or horizontal
|
||||
<code>UIScrollViewDecelerationRateFast</code> respectively.</p><ul><li><code>'normal'</code>: 0.998 (the default)</li><li><code>'fast'</code>: 0.99</li></ul></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="directionallockenabled"></a><span class="platform">ios</span>directionalLockEnabled?: <span class="propType">PropTypes.bool</span> <a class="hash-link" href="docs/scrollview.html#directionallockenabled">#</a></h4><div><p>When true, the ScrollView will try to lock to only vertical or horizontal
|
||||
scrolling while dragging. The default value is false.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="indicatorstyle"></a><span class="platform">ios</span>indicatorStyle?: <span class="propType">PropTypes.oneOf([
|
||||
'default', // default
|
||||
'black',
|
||||
'white',
|
||||
])</span> <a class="hash-link" href="docs/scrollview.html#indicatorstyle">#</a></h4><div><p>The style of the scroll indicators.
|
||||
- <code>default</code> (the default), same as <code>black</code>.
|
||||
- <code>black</code>, scroll indicator is black. This style is good against a light background.
|
||||
- <code>white</code>, scroll indicator is white. This style is good against a dark background.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="maximumzoomscale"></a><span class="platform">ios</span>maximumZoomScale?: <span class="propType">PropTypes.number</span> <a class="hash-link" href="docs/scrollview.html#maximumzoomscale">#</a></h4><div><p>The maximum allowed zoom scale. The default value is 1.0.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="minimumzoomscale"></a><span class="platform">ios</span>minimumZoomScale?: <span class="propType">PropTypes.number</span> <a class="hash-link" href="docs/scrollview.html#minimumzoomscale">#</a></h4><div><p>The minimum allowed zoom scale. The default value is 1.0.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="onscrollanimationend"></a><span class="platform">ios</span>onScrollAnimationEnd?: <span class="propType">PropTypes.func</span> <a class="hash-link" href="docs/scrollview.html#onscrollanimationend">#</a></h4><div><p>Called when a scrolling animation ends.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="scrolleventthrottle"></a><span class="platform">ios</span>scrollEventThrottle?: <span class="propType">PropTypes.number</span> <a class="hash-link" href="docs/scrollview.html#scrolleventthrottle">#</a></h4><div><p>This controls how often the scroll event will be fired while scrolling
|
||||
])</span> <a class="hash-link" href="docs/scrollview.html#indicatorstyle">#</a></h4><div><p>The style of the scroll indicators.</p><ul><li><code>'default'</code> (the default), same as <code>black</code>.</li><li><code>'black'</code>, scroll indicator is black. This style is good against a light background.</li><li><code>'white'</code>, scroll indicator is white. This style is good against a dark background.</li></ul></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="maximumzoomscale"></a><span class="platform">ios</span>maximumZoomScale?: <span class="propType">PropTypes.number</span> <a class="hash-link" href="docs/scrollview.html#maximumzoomscale">#</a></h4><div><p>The maximum allowed zoom scale. The default value is 1.0.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="minimumzoomscale"></a><span class="platform">ios</span>minimumZoomScale?: <span class="propType">PropTypes.number</span> <a class="hash-link" href="docs/scrollview.html#minimumzoomscale">#</a></h4><div><p>The minimum allowed zoom scale. The default value is 1.0.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="onscrollanimationend"></a><span class="platform">ios</span>onScrollAnimationEnd?: <span class="propType">PropTypes.func</span> <a class="hash-link" href="docs/scrollview.html#onscrollanimationend">#</a></h4><div><p>Called when a scrolling animation ends.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="scrolleventthrottle"></a><span class="platform">ios</span>scrollEventThrottle?: <span class="propType">PropTypes.number</span> <a class="hash-link" href="docs/scrollview.html#scrolleventthrottle">#</a></h4><div><p>This controls how often the scroll event will be fired while scrolling
|
||||
(as a time interval in ms). A lower number yields better accuracy for code
|
||||
that is tracking the scroll position, but can lead to scroll performance
|
||||
problems due to the volume of information being send over the bridge.
|
||||
@@ -119,10 +111,7 @@ The default value is true.</p></div></div><div class="prop"><h4 class="propTitle
|
||||
'center',
|
||||
'end',
|
||||
])</span> <a class="hash-link" href="docs/scrollview.html#snaptoalignment">#</a></h4><div><p>When <code>snapToInterval</code> is set, <code>snapToAlignment</code> will define the relationship
|
||||
of the snapping to the scroll view.
|
||||
- <code>start</code> (the default) will align the snap at the left (horizontal) or top (vertical)
|
||||
- <code>center</code> will align the snap in the center
|
||||
- <code>end</code> will align the snap at the right (horizontal) or bottom (vertical)</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="snaptointerval"></a><span class="platform">ios</span>snapToInterval?: <span class="propType">PropTypes.number</span> <a class="hash-link" href="docs/scrollview.html#snaptointerval">#</a></h4><div><p>When set, causes the scroll view to stop at multiples of the value of
|
||||
of the snapping to the scroll view.</p><ul><li><code>'start'</code> (the default) will align the snap at the left (horizontal) or top (vertical)</li><li><code>'center'</code> will align the snap in the center</li><li><code>'end'</code> will align the snap at the right (horizontal) or bottom (vertical)</li></ul></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="snaptointerval"></a><span class="platform">ios</span>snapToInterval?: <span class="propType">PropTypes.number</span> <a class="hash-link" href="docs/scrollview.html#snaptointerval">#</a></h4><div><p>When set, causes the scroll view to stop at multiples of the value of
|
||||
<code>snapToInterval</code>. This can be used for paginating through children
|
||||
that have lengths smaller than the scroll view. Used in combination
|
||||
with <code>snapToAlignment</code>.</p></div></div><div class="prop"><h4 class="propTitle"><a class="anchor" name="zoomscale"></a><span class="platform">ios</span>zoomScale?: <span class="propType">PropTypes.number</span> <a class="hash-link" href="docs/scrollview.html#zoomscale">#</a></h4><div><p>The current scale of the scroll view content. The default value is 1.0.</p></div></div></div><span><h3><a class="anchor" name="methods"></a>Methods <a class="hash-link" href="docs/scrollview.html#methods">#</a></h3><div class="props"><div class="prop"><h4 class="methodTitle"><a class="anchor" name="scrollto"></a>scrollTo<span class="methodType">(y?: number, object, x?: number, animated?: boolean)</span> <a class="hash-link" href="docs/scrollview.html#scrollto">#</a></h4><div><p>Scrolls to a given x, y offset, either immediately or with a smooth animation.</p><p>Example:</p><p><code>scrollTo({x: 0, y: 0, animated: true})</code></p><p>Note: The weird function signature is due to the fact that, for historical reasons,
|
||||
|
||||
Reference in New Issue
Block a user