3.12.2 • Published 3 months ago

react-slip-and-slide v3.12.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

react-slip-and-slide

A react and react-native carousel

Props

PropTypeDescription
refReactSlipAndSlideRefInstance reference that allow some external controls
dataT[]The shape data will be inferred from usage
snapboolean?Turns on offset snapping
centeredboolean?Centers the items on the container
infiniteboolean?Turns on infinite looping
pressToSlideboolean?Allows navigation when the next/prev item is pressed
animateStartupboolean?If true the slider will have an opacity transition when mounted. (can be useful to hide initial setup when itemWidth and/or itemHeight are not provided)
containerWidthnumber?The width of the items parent node (defaults to the width of the grand parent if undefined node)
overflowHiddenboolean?Allows the items to be visible when overflowing the parent container
fullWidthItemboolean?If true the items will assume the width of it's container. Useful if you leave containerWidth undefined to force it to fallback to 100%. The containerWidth will be measured for you and them containerWidth and itemWidth will be the same
animateStartupboolean?Animates opacity on start up
itemWidthnumber?The width of the items
itemHeightnumber?The height of the items
interpolators[key in keyof CSSProperties]: number / undefinedAllows you to define custom interpolation effects. For example, if opacity: 0.3, all items but the current will have opacity of 0.3, while the current will have 1. Be reasonable with this one as i'm not validating the properties
rubberbandElasticitynumber?The amount of elasticity when dragging beyond the container edges
visibleItemsnumber?The amount of rendered items at the same time
useWheelboolean?Allows you to control the slide gesture with the trackpad or mouse wheel
momentumMultipliernumber?Controls how much momentum the release will have when snap if false. To prevent bad UX the expected range is between 0 and 1
renderItem(props: RenderItemProps<T>) => JSX.ElementA function that have access to index and item props and returns a JSX.Element
onChangeonChange?: (index: number) => voidA callback that's fired when the index changes
onEdgesonEdges?: (props: {start: boolean; end: boolean;}) => voidA callback that's fired when the offset reaches both the start or end edges
onReadyonReady?: (ready: boolean) => voidonReady fires immediately if animateStartup is set to true otherwise it fires after the setup phase

Instance Ref

HandlerDescription
nextGo to next slide
nextGo to previous slide
goToGo to some index with an animation or not
moveMove the offset by the pixels provided (-x goes forward, x goes backwards)
const data = [
  {
    label: "Lorem",
  },
  {
    label: "Ipsum",
  },
  ...
];

function App() {

  const ref = React.useRef<ReactSlipAndSlideRef>(null);

  const prev = () => ref.current?.previous();
  const next = () => ref.current?.next();

  return (
    <div className="App">
      <ReactSlipAndSlide
        ref={ref}
        data={data}
        snap
        centered
        infinite
        pressToSlide
        itemWidth={420}
        itemHeight={400}
        interpolators={{
          opacity: 0.3,
          scale: 0.9,
        }}
        renderItem={({ index, item }) => {
          return (
            <img
              style={{ borderRadius: 80 }}
              src={`https://picsum.photos/seed/${index * 2}/400`}
              alt={item.label}
            />
          );
        }}
      />
    </div>
  );
}

Important! In order to get Android to work properly, you need to wrap your app with GestureHandlerRootView.

function App() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <ReactSlipAndSlide />
    </GestureHandlerRootView>
  );
}

Check out some examples

License

Licensed under the terms of the MIT License.

3.12.2

3 months ago

3.12.1

3 months ago

3.12.0

3 months ago

3.11.0

3 months ago

3.10.5

4 months ago

3.10.4

4 months ago

3.10.6

4 months ago

3.10.3

4 months ago

3.10.2

4 months ago

3.10.1

4 months ago

3.10.0

4 months ago

3.9.6

4 months ago

3.9.5

4 months ago

3.9.4

4 months ago

3.9.3

4 months ago

3.9.1

5 months ago

3.9.0

5 months ago

3.8.2

5 months ago

3.8.0

5 months ago

3.6.1

6 months ago

3.6.0

6 months ago

3.8.1

5 months ago

3.7.0

5 months ago

3.5.0

6 months ago

3.4.14

7 months ago

3.4.0

11 months ago

3.2.0

11 months ago

3.4.4

11 months ago

3.4.3

11 months ago

3.4.2

11 months ago

3.4.1

11 months ago

3.4.10

9 months ago

3.4.11

9 months ago

3.4.12

8 months ago

3.4.13

8 months ago

3.4.8

9 months ago

3.4.7

10 months ago

3.4.6

10 months ago

3.4.5

11 months ago

3.4.9

9 months ago

3.3.1

11 months ago

3.3.0

11 months ago

3.3.3

11 months ago

3.3.2

11 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.4

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

3.1.0

12 months ago

3.0.0

12 months ago

1.5.4

1 year ago

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago