Giter Site home page Giter Site logo

vue-swipe's Introduction

vue-swipe

vue-swipe is a touch slider for Vue.js.

Install

$ npm install vue-swipe

Import

Import using module

Import components to your project:

require('vue-swipe/dist/vue-swipe.css');

// in ES6 modules
import { Swipe, SwipeItem } from 'vue-swipe';

// in CommonJS
const { Swipe, SwipeItem } = require('vue-swipe');

// in Global variable
const { Swipe, SwipeItem } = VueSwipe;

And register components:

Vue.component('swipe', Swipe);
Vue.component('swipe-item', SwipeItem);

Import using script tag

<link rel="stylesheet" href="../node-modules/vue-swipe/dist/vue-swipe.css" charset="utf-8">
<script src="../node-modules/vue-swipe/dist/vue-swipe.js"></script>
const vueSwipe = VueSwipe.Swipe;
const vueSwipeItem = VueSwipe.SwipeItem;

new Vue({
  el: 'body',
  components: {
    'swipe': vueSwipe,
    'swipe-item': vueSwipeItem
  }
});

Usage

Work on a Vue instance:

<swipe class="my-swipe">
  <swipe-item class="slide1"></swipe-item>
  <swipe-item class="slide2"></swipe-item>
  <swipe-item class="slide3"></swipe-item>
</swipe>
.my-swipe {
  height: 200px;
  color: #fff;
  font-size: 30px;
  text-align: center;
}

.slide1 {
  background-color: #0089dc;
  color: #fff;
}

.slide2 {
  background-color: #ffd705;
  color: #000;
}

.slide3 {
  background-color: #ff2d4b;
  color: #fff;
}

Options

Props

Option Type Description Default
speed Number Speed of animation 300
defaultIndex Number Start swipe item index 0
disabled Boolean Disable user drag swipe item false
auto Number Delay of auto slide 3000
continuous Boolean Create an infinite slider without endpoints true
showIndicators Boolean Show indicators on slider bottom true
noDragWhenSingle Boolean Do not drag when there is only one swipe-item true
prevent Boolean preventDefault when touch start, useful for some lower version Android Browser (4.2, etc) false
propagation Boolean solve nesting false
disabled Boolean disabled user swipe item false

Events

Event Name Description params
change triggers when current swipe-item change new swipe item Index, old swipe item Index

FAQ

How to programminly swipe to an item?

Use ref and call goto() method.

this.$refs.swipe.goto(newIndex)

For more details, please refer to example code.

Development

Watching with hot-reload:

$ npm run dev

Develop on real remote device:

$ npm run remote-dev {{ YOUR IP ADDRESS }}

License

MIT

vue-swipe's People

Contributors

blackie4 avatar eric6356 avatar furybean avatar gogu avatar leopoldthecoder avatar peachscript avatar yongx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-swipe's Issues

图片超大时,滑动图片可能会导致页面不必要的重绘

发现可滑动的区域,并没有单独提升为一个层。所以在图片超大的情况下,可能会导致页面产生不必要的重绘。

见下图:

wechatimg43

解决方法就是在 .mint-swipe, .mint-swipe-items-wrap 这里面将滑动区域整体提升为一个单独的层

npm 同步

老哥,新版本同步npm啊~,现在npm还203呢,新的功能用不了。(~,~)

组件css问题

组件倒是引进去了,但是显示的效果不是那养的,应该横排但是是竖排的,好像css存在问题。
这个标签出现在了html文档中

sync with npm

hi~ I want to use v2.2.0 from npm, but the latest version on it is v2.0.3. How about sync with npm ?

兼容性bug

部分手机中 不能滑动
部分手机中不能自动切换
部分手机中点击会出现闪动

Web based demo?

Any chance you could add a web based demo so we could see it in action before cloning?

Failed to resolve directive: el (found in component <mt-swipe>)

`require('vue-swipe/dist/vue-swipe.css')

import { Swipe, SwipeItem } from 'vue-swipe'

export default ({
components: {
'swipe': Swipe,
'swipe-item': SwipeItem
}
})`

<template> <swipe class="my-swipe"> <swipe-item class="slide1">Slide1</swipe-item> <swipe-item class="slide2">Slide2</swipe-item> <swipe-item class="slide3">Slide3</swipe-item> </swipe> </template>

This code use to work with versions of Vue 2.0

组件化时报错?

<template>

    <swipe class="my-swipe">
        <swipe-item class="slide1"></swipe-item>
        <swipe-item class="slide2"></swipe-item>
        <swipe-item class="slide3"></swipe-item>
    </swipe>
</template>

<script>
require('vue-swipe/dist/vue-swipe.css');
// in ES6 modules
import { Swipe, SwipeItem } from 'vue-swipe';

export default {
  components: {
    'swipe': Swipe,
    'swipe-item': SwipeItem
  }
}
</script>

错误代码
[Vue warn]: You are using the runtime-only build of Vue where the template option is not available. Either pre-compile the templates into render functions, or use the compiler-included build. (found in component <mt-swipe>)

Invalid prop: type check failed for prop "auto". Expected Number, got String.

I get a [Vue warn] when I initialize the component like this:

<swipe auto="7000">

> [Vue warn]: Invalid prop: type check failed for prop "auto". Expected Number, got String. 
(found in component <mt-swipe>)

It seems to be parsing 7000 as a string, but for my purposes this is the simplest, most-straightforward way to configure this. Is there a better way to set this prop while keeping it as an attribute in the template?

Clickable indicators

Hello,

Is it possible to go to a page when clicked on the indicator in the bottom?

动态添加item

当数据是通过ajax请求回来时,通过v-for循环出来的swipe-item无法实现轮播效果,我试着通过$broadcast('swipeItemCreated')广播给组件初始化,但是还是不行,请问怎么解决。

Not support ssr ?

I have a problem using vue-swipe in my universal project, it seems doesn't support ssr cause I met a ReferenceError: document is not defined.

2016-11-07 5 32 37

This problem seems come from your wind-dom deps but I could not find the repo, can you guys fix this bug or add this feature? 😀

好不完善

1、没有索引按钮点击锚点
2、没有向上向下页翻转按钮扩展
3、没有回调方法吗?
4、再扩展下面索引的滑过的可以有方法回调(比如滑过可以显示缩略图)

整个页面的左右滑动

你好,现在我们有个需求是,页面顶部固定3个导航一排显示,下面的3个页面,可以左右划动切换,有什么实现思路吗

demo中左右来回滑动会出现奇怪现象

使用的时候发现左右滑动每次都会出现如图这种情况

vue-swipe

下面是我对代码做改动后的效果,原理是使用一个300%宽度的容器做左右滑动,而不是三个宽度100%的swipe-item同时滑动。

vue-swiper

Github生涯第一次提issue,请多多指教😊

代码在这里another vue-swipe

启动一段时间后,js开始报错

 <swipe class="my-swipe" :speed="900"  :show-indicators="true" :no-drag="false">
        <swipe-item class="slide1" v-on:click="swipeItemClick(1)">
            <img style="height: 6.4rem;width: 100%;" src="../../../resources/image/wtImg.png"/>
        </swipe-item>
        <swipe-item class="slide2" v-on:click="swipeItemClick(2)">
            <img style="height: 6.4rem;width: 100%;" src="../../../resources/image/wtImg.png"/>
        </swipe-item>
    </swipe>

import { Swipe, SwipeItem } from 'vue-swipe'

components:{Swipe, SwipeItem},

启动以后,自动运行一段时间开始报错,一共2处报错:
d4bd410d-8a72-4e96-becd-7cf6712529ff

require('vue-swipe/dist/vue-swipe.css');

当书写这句话时,提示错误:token (1:0)
vue-swipe.css Unexpected token (1:0) You may need an appropriate loader to handle this file type.

可是我是有cssloader的

固定方向的控制

在左右滑动的时候,页面同时可以进行上下滚动。体验很不好。
需要增加一个配置来处理这个问题

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.