Skip to content

Commit

Permalink
fixed min width container
Browse files Browse the repository at this point in the history
  • Loading branch information
yasaricli committed Aug 6, 2019
1 parent 453ebcc commit fd3f308
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export default class Dots extends Component {

static defaultProps = {
width: 300,

marginHorizontal: 2,
paddingVertical: 10,
paddingHorizontal: 10,

Expand Down Expand Up @@ -77,16 +79,17 @@ export default class Dots extends Component {
passiveColor,
activeBorder,
activeBorderWidth,
activeBorderColor
activeBorderColor,
marginHorizontal
} = this.props;
const width = isActive ? activeDotWidth : passiveDotWidth;

let style = {
width,
height: width,
marginHorizontal,
backgroundColor: isActive ? activeColor : passiveColor,
borderRadius: width,
marginHorizontal: 2,
marginTop: isActive ? -width / 6 : 0
};

Expand All @@ -100,14 +103,22 @@ export default class Dots extends Component {
}

render() {
const { length, width, paddingVertical, paddingHorizontal } = this.props;
const {
length,
width,
paddingVertical,
paddingHorizontal,
passiveDotWidth,
marginHorizontal
} = this.props;
const list = [...Array(length).keys()];
const scrollWidth = marginHorizontal * list.length * passiveDotWidth;

return (
<View style={Styles.container}>
<ScrollView
ref="_scrollView"
style={{ width }}
style={{ width: width < scrollWidth ? width : scrollWidth }}
contentContainerStyle={{ paddingVertical, paddingHorizontal }}
scalesPageToFit={scalesPageToFit}
bounces={false}
Expand Down

0 comments on commit fd3f308

Please sign in to comment.