Skip to content

Horizontal & vertical offset #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ var Carousel = React.createClass({
indicatorSize: 50,
inactiveIndicatorColor: '#999999',
indicatorAtBottom: true,
indicatorOffset: 250,
indicatorVerticalOffset: 250,
indicatorHorizontalOffset: 0,
indicatorText: '•',
inactiveIndicatorText: '•',
width: null,
Expand Down Expand Up @@ -68,13 +69,13 @@ var Carousel = React.createClass({
}

var indicators = [],
indicatorStyle = this.props.indicatorAtBottom ? { bottom: this.props.indicatorOffset } : { top: this.props.indicatorOffset },
indicatorStyle = this.props.indicatorAtBottom ? { bottom: this.props.indicatorVerticalOffset } : { top: this.props.indicatorVerticalOffset },
style, position;

position = {
width: this.props.children.length * this.props.indicatorSpace,
};
position.left = (this.getWidth() - position.width) / 2;
position.left = this.props.indicatorHorizontalOffset + (this.getWidth() - position.width) / 2;

for (var i = 0, l = this.props.children.length; i < l; i++) {
if (typeof this.props.children[i] === "undefined") {
Expand All @@ -83,9 +84,9 @@ var Carousel = React.createClass({

style = i === this.state.activePage ? { color: this.props.indicatorColor } : { color: this.props.inactiveIndicatorColor };
indicators.push(
<Text
style={[style, { fontSize: this.props.indicatorSize }]}
key={i}
<Text
style={[style, { fontSize: this.props.indicatorSize }]}
key={i}
onPress={this.indicatorPressed.bind(this,i)}
>
{ i === this.state.activePage ? this.props.indicatorText : this.props.inactiveIndicatorText }
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ indicatorSize={20} // Indicator bullet size
indicatorSpace={15} // space between each indicator
inactiveIndicatorColor="#999999" // Inactive indicator color
indicatorAtBottom={true} // Set to false to show the indicators at the top
indicatorOffset={250} // Indicator relative position from top or bottom
indicatorVerticalOffset={250} // Indicator relative position from top or bottom
indicatorHorizontalOffset={0} // Indicator relative position from center (horizontally)
onPageChange={callback} // Called when the active page changes
inactiveIndicatorText= '•' // Inactive indicator content ( You can customize to use any Unicode character )
indicatorText= '•' // Active indicator content ( You can customize to use any Unicode character )

animate={true} // Enable carousel autoplay
delay={1000} // Set Animation delay between slides
loop={true} // Allow infinite looped animation. Depends on Prop {...animate} set to true.
Expand Down