# Basic Slider

&#x20;Simple Slider with Simple API - No Dependency

![](/files/-LTxx5SImuzopQPL-0Pv)

***NOTE: This is purely for educational and learning purpose. Don't use this in production.***

[Documentation](https://dhavalvyas.gitbook.io/basic-slider/)

## Installations

Very easy setup. This is work in progress. CSS is not included in the library.

### HTML Markup

```markup
<div class="slider">
  <div class="item">
    <img src="image/url/name.jpg" /> <span>Slide 1</span>
  </div>
  <div class="item">
    <img src="image/url/name.jpg" /> <span>Slide 2</span>
  </div>
</div>
```

### Using `<script>`

*This is minified version.*

```markup
<script type="text/javascript" src="https://unpkg.com/@dhavalvyas/basic-slider/dist/index.js"></script>
```

Demo using direct `<script>` tag. [Basic Slider - Demo](https://codepen.io/cooldhavs/full/vvBKzr)

OR

### Using npm

`npm i @dhavalvyas/basic-slider`

Demo using direct `npm`. [Basic Slider - Demo](https://dhavalwd.github.io/basic-slider/)

## Instructions

### DEMO

Here is the codepen link for the current working demo.

[Basic Slider - Demo](https://codepen.io/cooldhavs/full/vvBKzr)

## Options

Some options to configure your slider. Below are default values.

```javascript
let slider = new BasicSlider({
  selector: '.slider',
  dotsWrapper: '.dots-wrapper',
  arrowLeft: '.arrow-left',
  arrowRight: '.arrow-right',
  loop: true,
  transition: {
    speed: 300,
    easing: 'ease-in'
  },
  onInit: (slider) => {
    console.log("onInit: slider Object ---> ", slider);
  },
  onSlideChange: (slider) => {
    console.log("onSlideChange: slider Object ---> ", slider);
  }
})
```

### Methods you can use

```javascript
// Re-initialize the slider
slider.reInit();

// Destroy slider
slider.destroy(() => {
  console.log("This is a callback once Slider is destroyed");
})
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dhavalvyas.gitbook.io/basic-slider/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
