Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Commit dfe6a42

Browse files
committed
added Pagination to web
1 parent fbf6d86 commit dfe6a42

File tree

6 files changed

+33
-16
lines changed

6 files changed

+33
-16
lines changed

index.android.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

3-
import Carousel from 'react-native-snap-carousel';
3+
import Carousel, { Pagination, getInputRangeFromIndexes } from 'react-native-snap-carousel';
44

55
module.exports = {
6-
Carousel
6+
Carousel,
7+
Pagination,
8+
getInputRangeFromIndexes
79
};

index.ios.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

3-
import Carousel from 'react-native-snap-carousel';
3+
import Carousel, { Pagination, getInputRangeFromIndexes } from 'react-native-snap-carousel';
44

55
module.exports = {
6-
Carousel
6+
Carousel,
7+
Pagination,
8+
getInputRangeFromIndexes
79
};

samples/CarouselTest/src/App.jsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* This file demonstrates basic usage of the Carousel component
33
*/
44

5-
let React, RX;
6-
React = RX = require('reactxp');
5+
let React = require('react');
6+
let RX = require('reactxp');
77

8-
let { Carousel } = require('reactxp-carousel');
8+
let { Carousel, Pagination } = require('reactxp-carousel');
99

1010
const _styles = {
1111
slide: RX.Styles.createViewStyle({
@@ -49,6 +49,11 @@ const entries = [
4949

5050
class App extends RX.Component {
5151

52+
state = {
53+
index: 0
54+
}
55+
carouselRef = React.createRef();
56+
5257
_renderItem ({item, index}) {
5358
return (
5459
<RX.View style={_styles.slide}>
@@ -71,12 +76,13 @@ class App extends RX.Component {
7176
const sliderWidth = width;
7277
const itemWidth = slideWidth + itemHorizontalMargin * 2;
7378

74-
const type = 'tinder';
79+
const type = 'default';
7580

7681
return (
7782
<RX.View style={[_styles.exampleContainer, _styles.exampleContainerDark]}>
7883
<Carousel
7984
data={entries}
85+
ref={this.carouselRef}
8086
renderItem={this._renderItem}
8187
sliderWidth={sliderWidth}
8288
itemWidth={itemWidth}
@@ -86,8 +92,17 @@ class App extends RX.Component {
8692
inactiveSlideOpacity={0.1}
8793
inactiveSlideScale={0.5}
8894
vertical={false}
95+
onSnapToItem={(index) => this.setState({ activeSlide: index })}
8996
autoplay={false}
9097
/>
98+
<Pagination
99+
dotsLength={entries.length}
100+
activeDotIndex={this.state.activeSlide}
101+
inactiveDotOpacity={0.4}
102+
inactiveDotScale={0.6}
103+
tappableDots={true}
104+
carouselRef={this.carouselRef.current}
105+
/>
91106
</RX.View>
92107
);
93108
}

src/carousel/Carousel.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,6 @@ export class Carousel extends Component {
11751175
const animate = this._shouldAnimateSlides();
11761176
const Component = animate ? Animated.View : View;
11771177
const animatedStyle = animate ? this._getSlideInterpolatedStyle(index, animatedValue) : {};
1178-
console.log(animatedStyle)
11791178

11801179
const parallaxProps = hasParallaxImages ? {
11811180
scrollPosition: this._scrollPos,

src/pagination/Pagination.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React, { PureComponent } from 'react';
1+
let React = require('react');
22
import { International, View } from 'reactxp';
33
var PropTypes = require('prop-types');
44
import PaginationDot from './PaginationDot';
55
import styles from './Pagination.style';
66

77
const IS_RTL = International.isRTL();
88

9-
export class Pagination extends PureComponent {
9+
export class Pagination extends React.PureComponent {
1010

1111
static propTypes = {
1212
activeDotIndex: PropTypes.number.isRequired,

src/pagination/PaginationDot.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, { PureComponent } from 'react';
1+
let React = require('react');
22
import { View, Animated } from 'reactxp';
33
var PropTypes = require('prop-types');
44
import styles from './Pagination.style';
55

6-
export default class PaginationDot extends PureComponent {
6+
export default class PaginationDot extends React.PureComponent {
77

88
static propTypes = {
99
inactiveOpacity: PropTypes.number.isRequired,
@@ -53,9 +53,8 @@ export default class PaginationDot extends PureComponent {
5353
easing: Animated.Easing.linear,
5454
...commonProperties
5555
}),
56-
Animated.spring(animTransform, {
57-
friction: 4,
58-
tension: 50,
56+
Animated.timing(animTransform, {
57+
easing: Animated.Easing.linear,
5958
...commonProperties
6059
})
6160
];

0 commit comments

Comments
 (0)