Skip to content

Commit

Permalink
feat(react-web): support multiple instance
Browse files Browse the repository at this point in the history
  • Loading branch information
xxs665 authored and xuqingkuang committed Feb 25, 2020
1 parent 96e278d commit c5fb93b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/hippy-react-web/src/components/view-pager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class ViewPager extends Component {
}

componentDidMount() {
const { initialPage = 0, onPageSelected } = this.props;
this.viewPagerSwiper = new Swiper('.swiper-container', {
const { initialPage = 0, onPageSelected, scrollEnabled } = this.props;
this.viewPagerSwiper = new Swiper(this.containerRef, {
initialSlide: initialPage,
autoHeight: true,
on: {
Expand All @@ -27,6 +27,7 @@ export class ViewPager extends Component {
if (onPageSelected) onPageSelected({ position: this.activeIndex });
},
},
allowTouchMove: !!scrollEnabled,
});
}

Expand All @@ -38,7 +39,7 @@ export class ViewPager extends Component {

setPageWithoutAnimation(index: number) {
if (Number.isInteger(index)) {
this.viewPagerSwiper.slideTo(index);
this.viewPagerSwiper.slideTo(index, 0);
}
}

Expand All @@ -53,7 +54,7 @@ export class ViewPager extends Component {
};
return (
<div style={style}>
<div className="swiper-container" style={style}>
<div ref={(ref) => { this.containerRef = ref; }} className="swiper-container" style={style}>
<div className="swiper-wrapper">
{renderViewPagerItem()}
</div>
Expand Down

0 comments on commit c5fb93b

Please sign in to comment.