Skip to content

Commit

Permalink
fix(taro-components-rn): scrollview 横向
Browse files Browse the repository at this point in the history
  • Loading branch information
Manjiz committed Feb 18, 2019
1 parent 2ecff34 commit b1e610d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/taro-components-rn/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default class App extends Component {
onScroll={(e) => {
console.log('onScroll', e)
}}
// scrollX={true}
>
<Text>Welcome to React Native!</Text>

Expand Down
12 changes: 7 additions & 5 deletions packages/taro-components-rn/src/components/ScrollView/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* scroll-x: Either-or
* ✘ scroll-y: Either-or
* ✔ scrollX(scroll-x): Either-or
* ✘ scrollY(scroll-y): Either-or
* ✔ upperThreshold(upper-threshold)
* ✔ lowerThreshold(lower-threshold)
* ✔ scrollTop(scroll-top)
Expand All @@ -25,7 +25,7 @@ import { dismemberStyle, omit } from '../../utils'
type Props = {
children?: React.Node,
style?: StyleSheet.Styles,
horizontal?: boolean,
scrollX?: boolean,
upperThreshold: number,
lowerThreshold: number,
scrollTop: number,
Expand Down Expand Up @@ -76,11 +76,11 @@ class _ScrollView extends React.Component<Props> {
_initialScrollIndexTimeout: any

_selectLength = (metrics: { height: number, width: number }): number => {
return !this.props.horizontal ? metrics.height : metrics.width
return !this.props.scrollX ? metrics.height : metrics.width
}

_selectOffset = (metrics: {x: number, y: number}): number => {
return !this.props.horizontal ? metrics.y : metrics.x
return !this.props.scrollX ? metrics.y : metrics.x
}

_maybeCallOnStartReached = () => {
Expand Down Expand Up @@ -210,6 +210,7 @@ class _ScrollView extends React.Component<Props> {
const {
children,
style,
scrollX,
enableBackToTop,
} = this.props

Expand All @@ -219,6 +220,7 @@ class _ScrollView extends React.Component<Props> {

return (
<ScrollView
horizontal={scrollX}
onContentSizeChange={this._onContentSizeChange}
onLayout={this._onLayout}
onScroll={this._onScroll}
Expand Down

0 comments on commit b1e610d

Please sign in to comment.