rn-viewpager
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -9,3 +9,4 @@ # <IndicatorViewPager /> Component Api | ||
| autoPlayInterval | number | 3000 | | | ||
| horizontalScroll | bool | true | | | ||
@@ -13,3 +13,4 @@ # <IndicatorViewPager /> Component Api | ||
| selectedTextStyle | Text.propTypes.style | | | | ||
| changePageWithAnimation | PropTypes.bool | true | | | ||
{ | ||
"name": "rn-viewpager", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "ViewPager component for react-native, same api on both android and ios.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,3 +6,4 @@ /** | ||
'use strict' | ||
import React, { Component, PropTypes } from 'react' | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { StyleSheet, View } from 'react-native' | ||
@@ -20,3 +21,3 @@ import IndicatorViewPager from '../IndicatorViewPager' | ||
selectedDotStyle: View.propTypes.style, | ||
hideSingle: React.PropTypes.bool | ||
hideSingle: PropTypes.bool | ||
} | ||
@@ -23,0 +24,0 @@ |
@@ -6,3 +6,4 @@ /** | ||
'use strict' | ||
import React, { Component, PropTypes } from 'react' | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { StyleSheet, View, Image, Text, TouchableOpacity } from 'react-native' | ||
@@ -26,7 +27,9 @@ import IndicatorViewPager from '../IndicatorViewPager' | ||
textStyle: Text.propTypes.style, | ||
selectedTextStyle: Text.propTypes.style | ||
selectedTextStyle: Text.propTypes.style, | ||
changePageWithAnimation: PropTypes.bool, | ||
} | ||
static defaultProps = { | ||
tabs: [] | ||
tabs: [], | ||
changePageWithAnimation: true | ||
} | ||
@@ -41,3 +44,3 @@ | ||
tabs, pager, style, itemStyle, selectedItemStyle, iconStyle, | ||
selectedIconStyle, textStyle, selectedTextStyle | ||
selectedIconStyle, textStyle, selectedTextStyle, changePageWithAnimation | ||
} = this.props | ||
@@ -53,3 +56,9 @@ if (!tabs || tabs.length === 0) return null | ||
key={index} | ||
onPress={() => {!isSelected && pager.setPage(index)}} | ||
onPress={() => { | ||
if (!isSelected){ | ||
if (this.props.changePageWithAnimation) | ||
pager.setPage(index); | ||
else pager.setPageWithoutAnimation(index); | ||
} | ||
}} | ||
> | ||
@@ -56,0 +65,0 @@ <Image |
@@ -7,3 +7,4 @@ /** | ||
import React, { Component, PropTypes } from 'react' | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native' | ||
@@ -23,3 +24,3 @@ import IndicatorViewPager from '../IndicatorViewPager' | ||
selectedBorderStyle: View.propTypes.style, | ||
renderTitle: React.PropTypes.func | ||
renderTitle: PropTypes.func | ||
} | ||
@@ -26,0 +27,0 @@ |
@@ -7,3 +7,4 @@ /** | ||
import React, { Component, PropTypes } from 'react' | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { StyleSheet, View } from 'react-native' | ||
@@ -20,3 +21,4 @@ import ViewPager from './ViewPager' | ||
autoPlayEnable: PropTypes.bool, | ||
autoPlayInterval: PropTypes.number | ||
autoPlayInterval: PropTypes.number, | ||
horizontalScroll: PropTypes.bool | ||
} | ||
@@ -28,3 +30,4 @@ | ||
autoPlayInterval: 3000, | ||
autoPlayEnable: false | ||
autoPlayEnable: false, | ||
horizontalScroll: true | ||
} | ||
@@ -63,2 +66,3 @@ | ||
{...this.props} | ||
horizontalScroll={this.props.horizontalScroll} | ||
ref={VIEWPAGER_REF} | ||
@@ -65,0 +69,0 @@ style={[styles.pager, this.props.pagerStyle]} |
@@ -7,4 +7,4 @@ /** | ||
import { PanResponder, Platform, ScrollView, StyleSheet, View, ViewPagerAndroid } from 'react-native' | ||
import React, { Component } from 'react' | ||
import { StyleSheet, View, ViewPagerAndroid, ScrollView, Platform, PanResponder } from 'react-native' | ||
@@ -61,5 +61,6 @@ const SCROLLVIEW_REF = 'scrollView' | ||
render () { | ||
return Platform.OS === 'ios' ? this._renderOnIOS() : ( | ||
return (this.props.forceScrollView || Platform.OS === 'ios') ? this._renderOnIOS() : ( | ||
<ViewPagerAndroid | ||
{...this.props} | ||
scrollEnabled={this.props.horizontalScroll ? true : false} | ||
ref={VIEWPAGER_REF} | ||
@@ -90,3 +91,3 @@ onPageScroll={this._onPageScrollOnAndroid} | ||
horizontal: true, | ||
pagingEnabled: true, | ||
pagingEnabled: this.props.horizontalScroll ? true : false, | ||
scrollsToTop: false, | ||
@@ -164,3 +165,3 @@ showsHorizontalScrollIndicator: false, | ||
setPageWithoutAnimation (selectedPage) { | ||
if (Platform.OS === 'ios') | ||
if (this.props.forceScrollView || Platform.OS === 'ios') | ||
this.refs[SCROLLVIEW_REF].scrollTo({x: this.state.width * selectedPage, animated: false}) | ||
@@ -174,3 +175,3 @@ else { | ||
setPage (selectedPage) { | ||
if (Platform.OS === 'ios') this.refs[SCROLLVIEW_REF].scrollTo({x: this.state.width * selectedPage}) | ||
if (this.props.forceScrollView || Platform.OS === 'ios') this.refs[SCROLLVIEW_REF].scrollTo({x: this.state.width * selectedPage}) | ||
else { | ||
@@ -177,0 +178,0 @@ this.refs[VIEWPAGER_REF].setPage(selectedPage) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3824047
628