1.1.27 • Published 9 months ago

react-swipeable-views-v18 v1.1.27

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

React Swipeable Views v18

A replacement for react swipeable views for React 18.

Installation

npm install react-swipeable-views-v18

Usage

import React, { useRef } from 'react';
import {SwipeableViews} from 'react-swipeable-views';

const App = () => {
  const swipeableViewsRef = useRef(null);

  const handleSwipeForward = () => {
    swipeableViewsRef.current.swipeForward();
  };

  const handleSwipeBackward = () => {
    swipeableViewsRef.current.swipeBackward();
  };

  const handleResetPosition = () => {
    swipeableViewsRef.current.resetPosition();
  };

  return (
    <div>
      <SwipeableViews ref={swipeableViewsRef}>
        <div>View 1</div>
        <div>View 2</div>
        <div>View 3</div>
      </SwipeableViews>

      <button onClick={handleSwipeBackward}>Swipe Backward</button>
      <button onClick={handleSwipeForward}>Swipe Forward</button>
      <button onClick={handleResetPosition}>Reset Position</button>
    </div>
  );
};

export default App;

Features

  • Swipeable views for React 18.
  • Auto-swipe feature with customizable interval.
  • Manual navigation with forward and backward buttons.
  • Customizable button text.
  • Adjustable swipe threshold.
  • Looping behavior for infinite swiping.

Props

PropTypeDefaultDescription
autoSwipebooleanfalseEnable or disable auto-swipe feature.
autoSwipeIntervalnumber3000Auto-swipe interval in milliseconds.
backButtonPropsobjectProps for the backward button.
forwardButtonPropsobjectProps for the forward button.
swipeThresholdnumber50Drag threshold for swipe action.
loopbooleantrueEnable or disable looping behavior.
hideBackButtonbooleanfalseHide the backward button.
hideForwardButtonbooleanfalseHide the forward button.

backButtonProps

PropTypeDefaultDescription
textstring'Back'The text content of the back button.
disabledbooleanfalseDisable the back button.

forwardButtonProps

PropTypeDefaultDescription
textstring'Next'The text content of the forward button.
disabledbooleanfalseDisable the forward button.

Customization

You can customize the appearance and behavior of the SwipeableViews component by modifying the CSS classes or adding inline styles. The component uses the following CSS classes:

  • swipeable-container: The container element that wraps the swipeable views.
  • slider-container: The container for the views that is translated to achieve the swipe effect.
  • slide: The individual view elements.
  • pagination: The pagination dots for navigating between views.
  • dot: The individual dot element representing a view in the pagination.
  • dot.active: The active dot element indicating the current view.
  • .buttons-container > button: The forward and backward buttons.
  • .buttons-container > button.disabled: The disabled forward and backward buttons.
  • .buttons-container: The container for the forward and backward buttons. -.buttons-container > button:after: The text content of the forward and backward buttons.
  • .buttons-container > button:disabled:after: The text content of the disabled forward and backward buttons.
  • .buttons-container > button:active:after: The text content of the active forward and backward buttons.

You can override these classes or provide additional styles to achieve the desired look and feel.

Contributing

Contributions are welcome! If you find a bug or want to suggest an enhancement, please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

1.1.27

9 months ago

1.1.25

11 months ago

1.1.24

11 months ago

1.1.23

11 months ago

1.1.22

11 months ago

1.1.21

11 months ago

1.1.20

11 months ago

1.1.19

11 months ago

1.1.18

11 months ago

1.1.17

11 months ago

1.1.16

11 months ago

1.1.15

11 months ago

1.1.14

11 months ago

1.1.13

11 months ago

1.1.12

11 months ago

1.1.11

11 months ago

1.1.10

11 months ago

1.1.9

11 months ago

1.1.8

11 months ago

1.1.7

11 months ago

1.1.6

11 months ago

1.1.5

11 months ago

1.1.4

11 months ago

1.1.3

11 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.42

11 months ago

1.0.41

11 months ago

1.0.40

11 months ago

1.0.39

11 months ago

1.0.38

11 months ago

1.0.37

11 months ago

1.0.36

11 months ago

1.0.35

11 months ago

1.0.34

11 months ago

1.0.33

11 months ago

1.0.32

11 months ago

1.0.31

11 months ago

1.0.30

11 months ago

1.0.29

11 months ago

1.0.28

11 months ago

1.0.27

11 months ago

1.0.26

11 months ago

1.0.25

11 months ago

1.0.24

11 months ago

1.0.23

11 months ago

1.0.22

11 months ago

1.0.21

11 months ago

1.0.20

11 months ago

1.0.19

11 months ago

1.0.17

11 months ago

1.0.16

11 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

11 months ago

1.0.11

11 months ago

1.0.10

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago