Code Monkey home page Code Monkey logo

image-slider's Introduction

Simple Image Slider

A very minimal image slider, built using React.

Motivation

For a long time learning React now, I finally decided to build something more complex in it than those mere counter programs that, although are really good for beginners trying to understand how react works and get started with it, don't really serve as good examples to build one's skills in React.

Already having a great amount of experience building image sliders of many kinds in vanilla JS under my belt, I thought of building an image slider using React. It's not that simple and even not that complicated โ€” just perfect for what I wanted to build at this time. ๐Ÿ™‚

The Slider component

To add a slider, we just need to include the Slider component along with its data prop, which holds an array of image URLs that will ultimately be shown in the slider, and its width and height props, which specify its width and height proportions, respectively:

<Slider data={[/* Array of URLs of images */]} width={1366} height={768} />

Configurations

I've tried to keep the slider as much flexible as I could've, so that it could easily be configured for one's needs. The following props can be used to customize it:

  • pagination: A Boolean value specifying whether pagination should be applied to the slider or not. By default, it's false.
  • initial: Specifies the index of the slide which should be shown initially. By default, it's 0, i.e. the very first slide.
  • repeat: A Boolean value specifying whether the slides should repeat when we reach the very first or the very last slide. By default, it's false.
  • keyHandling: A Boolean value specifying whether key-based navigation should be enabled. This allows us to navigate the slider by using the arrow keys on the keyboard. By default, it's false as well.

image-slider's People

Contributors

bilalbro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.