1.0.8 • Published 1 year ago

react-3d-slider v1.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

React 3D image slider

A customizable 3D image slider React component.

Installation

npm install react-3d-slider

Usage

import React from 'react';
import ImageSlider from 'react-3d-slider';

const App = () => {
  const images = [
    { id: 1, path: 'https://example.com/image1.jpg' },
    { id: 2, path: 'https://example.com/image2.jpg' },
    { id: 3, path: 'https://example.com/image3.jpg' },
    { id: 4, path: 'https://example.com/image4.jpg' },
    { id: 5, path: 'https://example.com/image5.jpg' },
  ];

  return (
    <div>
      <h1>3D Image Slider</h1>
      <ImageSlider
        images={images}
        width={400}
        height={300}
        autoRotateInterval={5000}
        centerScale={1.2}
        sideScale={0.8}
        outerScale={0.6}
        centerBlur={0}
        sideBlur={2}
        outerBlur={4}
      />
    </div>
  );
};

export default App;

Props

The ImageSlider component accepts the following props:

PropTypeDefaultDescription
imagesarrayrequiredAn array of image URLs to be displayed in the slider
widthnumber300Width of the slider container in pixels
heightnumber400Height of the slider container in pixels
autoRotateIntervalnumber10000Interval for automatic rotation in milliseconds
centerScalenumber1Scale factor for the center image
sideScalenumber0.8Scale factor for the side images
outerScalenumber0.6Scale factor for the outer images
centerBlurnumber0Blur amount for the center image in pixels
sideBlurnumber1Blur amount for the side images in pixels
outerBlurnumber2Blur amount for the outer images in pixels
onImageClicknumber2Callback function when an image is clicked, receives the image id as an argument

Advanced Usage

import React from 'react';
import ImageSlider from 'react-3d-slider';

const App = () => {
  const images = [
    { id: 1, path: 'https://example.com/image1.jpg' },
    { id: 2, path: 'https://example.com/image2.jpg' },
    { id: 3, path: 'https://example.com/image3.jpg' },
    { id: 4, path: 'https://example.com/image4.jpg' },
    { id: 5, path: 'https://example.com/image5.jpg' },
  ];

  const handleImageClick = (image) => {
    console.log(image);
  };

  return (
    <div>
      <h1>Custom 3D Image Slider</h1>
      <ImageSlider
        images={images}
        width={500}
        height={300}
        autoRotateInterval={5000}
        centerScale={1.2}
        sideScale={0.8}
        outerScale={0.5}
        centerBlur={0}
        sideBlur={2}
        outerBlur={4}
        onImageClick={handleImageClick}
      />
    </div>
  );
};

export default App;

Links

Preview

Alt text

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any problems or have any questions, please open an issue on the GitHub repository.

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago