Giter Club home page Giter Club logo

vue-slider's Introduction

中文 | English ##vue-slider.js


vue-slider,一个简单的滑动组件,配置简单,支持自适应/全屏+按钮+分页,同时兼容移动端和PC端

###目前已实现

  • 全屏自适应
  • 移动端兼容
  • 垂直滚动
  • 定时自动切换
  • 不定宽度滚动
  • 无缝循环滚动

###未来将实现

  • 渐变滚动
  • 视差效果

###例子

slider效果 完整文档

###快速开始使用

通过以下demo来实现

###app.vue父级组件

<template>
  <slider :pages="someList" :sliderinit="sliderinit">
    <!-- slot  -->
  </slider>
</template>

<script>
import slider from './slider'// 引入slider组件
export default {
   el: '#app',
   data () {
      return {
        //图片列表[arr]
        pages:[
          {
            title: '',
            style:{
             background:'url(src/img/testimg-1.jpg)'
            }
          },
          {
           title: '',
           style:{
            background:'url(src/img/testimg-2.jpg)'
            }
          },
          {
            title: 'slide3',
            style:{
              background:'#4bbfc3',
            },
          }
        ],
        //滑动配置[obj]
        sliderinit: {
          // 写了一些无需配置的项,下个版本会放到slider设定默认值
          currentPage: 0,//当前页码
          start: {},//默认需要书写,存放点击位置
          end: {},//默认需要书写,存放点击位置
          tracking: false,//swipestart状态判断
          thresholdDistance: 500,//滑动判定距离
          thresholdTime: 100,//滑动判定时间
          autoplay:1000,//自动滚动[ms]
          loop:true//循环滚动
          direction:'vertical'//方向设置,垂直滚动
        }
      }
    },
    components: {
        slider
    }
}
</script>

###pages/初始化参数

Option Type Default Description
title string - 当前设置为每页的标题,未来将直接输出html
style obj - 直接作用在每个item上的style样式,可以输出背景图,背景色,每项宽度可自定义,自动切换为不定宽滚动
###sliderinit/初始化参数
Option Type Default Description
direction string 'horizontal' 方向设置,默认为水平滚动('horizontal'),可设置为垂直滚动('vertical')
currentPage number - 当前为第几页
thresholdDistance number - 滑动距离阈值
thresholdTime number - 滑动时间阈值
autoplay number[ms] - 自动播放:时间[ms]
loop boolean false 循环滚动
###API/父级传递的事件
Method Parameters Description Example
slideTo number 滑动到(number)页 this.$broadcast('slideTo', num)
slideNext - 滑动到下一页 this.$broadcast('slideNext')
slideTo - 滑动到上一页 this.$broadcast('slidePre')
###API/父级监听的事件
Method Parameters Description Example
slide number 当前滑动到第(number)页 vm.$on('slide', function(pagenum){console.log(pagenum)})

###有更好的想法? 欢迎来留下你的意见:warpcgd#1

###BUG?oh no! 可以在这里提交,会尽快处理:warpcgd#2

vue-slider's People

Contributors

warpcgd avatar

Watchers

athiwatp 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.