1.3.3 • Published 5 years ago

vue-html-slider v1.3.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

vue-html-slider

npm downloads license

A simple, light and configurable vue silder component.

Install

use npm

npm install vue-html-slider

use yarn

yarn add vue-html-slider

Get Started

Just one property is required to start the slider as follows.

<!--vue template-->
<template> 
  <vue-html-slider :data="images"></vue-html-slider>
</template>
<script>
  import vueHtmlSlider from 'vue-html-slider';
  export default {
    components: {
      'vue-html-slider': vueHtmlSlider
    },
    data() {
      return {
        images: [
          'http://path/to/a.png',
          'http://path/to/b.png'
        ]
      }
    }
  }
</script>

With just a few steps, you can create a slider application. As well, there is an online demo which provides a real experience for you.

avatar

Advanced

Slider defines many properties for customizing what you want. You can set the options property to slider as follow.

<template> 
  <vue-html-slider :options="options"></vue-html-slider>
</template>
<script>
  // ...
  export default {
    // ...
    data() {
      return {
        options: {
          index: 0,
          lazyload: true,
          useFade: true,
          click() {
            // user click event callback.
          }
        }
      }
    }
  }
</script>

The options contains many properties. All properties are listed below.

PropertyTypedefault/paramsDescription
indexNumber0Default image position index.
autoplayBooleanfalseWhether autoplay, not implement.
intervalNumber1000Autoplay interval mills, not implement.
loopBooleanfalsePlaying slider with loop, not implement.
clsNameString-Apply a css class on image element.
gapWidthNumber0You can set a gap between each image.
useFadeBooleanfalseApply fade animation to image when appears.
lazyloadBooleanfalseThe image will be loaded only appears, if true.
zoomBooleanfalseYou can zoom picture scale by gesture if set true, not implement.
loadingString-It will be shown before loaded. A html template or characters are supported.
errorString-It will be shown after load error. A html template or characters are supported.
hideIndicatorBoolenfalseWhether hide page number on bottom of image. As well, it can display 20 indicators at most.
isDebugBooleanfalseIn Debug mode, slider will print some log infos by console.log.
disableBounceBoolenfalseWhether disable bounce when reached slider boundary.
changedFunctionimageIt will be fired when image position changed.
clickFunctionimageA click event fired on image element.
longTapFunctionimageA longTap event on image element.
longTapEndFunctionimageIt will be fired when the longTap event completes.

Pull-left / Pull-right

You can move more when reached slider left or right boundary if you set disableBounce false. So, you can listen the event by setting the pull-left or pull-right property to slider as follows.

<template>
  <vue-html-slider :pull-left="pullLeft"></vue-html-slider>
</template>
<script>
  // ...
  export default {
    // ...
    data() {
      return {
        pullLeft: {
          tpl: '<div class="foo">query all</div>',
          pull(x) {
            // pulling continuously.
          },
          release(x) {
            // released.
          }
        }
      }
    }
  }
</script>

The pull-left and pull-right have three properties respectively as follows.

PropertyTypeparamsDescription
tplString-A html template will be shown when beyond slider boundary. Characters are also supported.
pullFunctionxA pull event will be fired continuously before released.
releaseFunctionxA release event will be fired when released.

The pull or release parameter x refers to the distance that page leaves the boundary which is an absolute value.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago