• Stars
    star
    148
  • Rank 249,983 (Top 5 %)
  • Language Vue
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

IScroll-view component for Vue 2.x

npm version

vue-iscroll-view

IScroll component for Vue 2.x

Demo

https://dafrok.github.io/vue-iscroll-view/

Built with vue-iscroll-view

Install

$ npm i vue-iscroll-view
$ npm i iscroll

Get Start

import IScrollView from 'vue-iscroll-view'

/* Using these kinds of IScroll class for different cases. */
import IScroll from 'iscroll'
// import IScroll from 'iscroll/build/iscroll-infinite.js
// import IScroll from 'iscroll/build/iscroll-probe.js
// import IScroll from 'iscroll/build/iscroll-view.js
// import IScroll from 'iscroll/build/iscroll-zoom.js
// import IScroll from 'iscroll/build/iscroll-lite.js

Vue.use(IScrollView, IScroll)
<template>
  <iscroll-view class="scroll-view">
    Your contents
  </iscroll-view>
</tempalte>

<style>
.scroll-view {
  /* -- Attention: This line is extremely important in chrome 55+! -- */
  touch-action: none;
  /* -- Attention-- */
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  overflow: hidden;
}
</style>

Usage

Set IScroll options

<template>
  <iscroll-view :options="{preventDefault: false}">
    Your contents
  </iscroll-view>
</tempalte>

Listen IScroll events

<template>
  <iscroll-view @scrollStart="log">
    Your contents
  </iscroll-view>
</tempalte>

<script>
export default {
  methods: {
    log (iscroll) {
      console.log(iscroll)
    }
  }
}
</script>

Call IScroll instance functions

<template>
  <div>
    <iscroll-view ref="iscroll">
      Your contents
    </iscroll-view>
    <button @click="scrollToTop">Scroll To Top</button>
  </div>
</tempalte>

<script>
export default {
  methods: {
    scrollToTop () {
      const iscroll = this.$refs.iscroll
      iscroll.scrollTo(0, 0, 100)
      iscroll.refresh()
    }
  }
}
</script>

Custom events

  • pullUp
  • pullDown
<template>
  <iscroll-view @pullUp="load" @pullDown="refresh">
    Your contents
  </iscroll-view>
</tempalte>

<script>
export default {
  methods: {
    refresh (iscroll) {
      // Refresh current data
    },
    load (iscroll) {
      // Load new data
    }
  }
}
</script>

The Scroller

Each iscroll instance contains a wrapper and a scroller, the <iscroll-view> element is simply a reference the wrapper. If you need to take control of the scroller, the following case may help you.

<template>
  <iscroll-view ref="iscroll" :scrollerStyle="{color: 'red'}" scrollerClass="{scroller: true}">
    Your contents
  </iscroll-view>
</tempalte>

<script>
export default {
  mounted () {
    /* Get the reference of the scroller */
    const $scroller = this.$refs.iscroll.$refs.scroller
    console.log($scroller)
  }
}
</script>

<style scoped>
.scroller {
  background: blue
}
</style>

More Repositories

1

vue-baidu-map

Baidu Map components for Vue 2.x
Vue
2,413
star
2

v-hotkey

Vue 2.x directive for binding hotkeys to components.
JavaScript
721
star
3

fuck-ie

Check whether your browser is a f**king specified version of IE or not.
JavaScript
46
star
4

if-emoji

Check a character if it is a correctly supported emoji.
JavaScript
40
star
5

clip-it

A totally easy way for modern browsers to put something into clipboard.
JavaScript
12
star
6

dafrok.github.io

Blog
JavaScript
10
star
7

mysql-backup

JavaScript
6
star
8

BMapLib.MarkerClusterer

JavaScript
6
star
9

vue-fitd

Vue UI Library & FIT Design
Vue
5
star
10

game-pick-it-up

Game: Pick it up!
JavaScript
5
star
11

san-mixin

mixin function for san components
JavaScript
5
star
12

form-to-from

An ATOM plugin which helps you spell "from" right.
JavaScript
4
star
13

webpack2-docker

JavaScript
3
star
14

gzip-size-online

A tool for measuring the gzip size of a file online
JavaScript
3
star
15

BMapLib.LuShu

An UMD module of BaiduMap LuShu library.
JavaScript
3
star
16

thrash

别看了,没什么正经东西,划水用的。
HTML
3
star
17

css-color-playground

Easily transforming & copy your CSS color to other formats.
HTML
3
star
18

issues-bot

Webhook for issues
JavaScript
2
star
19

react-shortcut-key

Shortcut key wrapper for react components.
JavaScript
2
star
20

color-factory

CSS colors converter
JavaScript
2
star
21

deep-empty-object

JavaScript
1
star
22

cocalc

HTML
1
star
23

sheikah.dafrok.top

Sheikah language panel
JavaScript
1
star
24

issue-of-vue-loader

Deprecated
JavaScript
1
star
25

illiterate-editor

文盲编辑器,成为文盲不再是梦想。
JavaScript
1
star
26

ewent

Connect browser windows by events.
JavaScript
1
star
27

Pianer

An app for photographers and cosplayers
HTML
1
star
28

Weboy

CSS
1
star
29

f-check

JavaScript
1
star
30

Mobum.js

Mobile Album
JavaScript
1
star
31

awesome-docker-libraries

1
star
32

npud

Show the update date of npm packages dependencies in your project.
JavaScript
1
star
33

buy-buy-buy

1
star
34

BMapLib.TextIconOverlay

JavaScript
1
star
35

rndgen

Vue
1
star
36

abmid.js

Fix DOM elements always in the middle of the wrapper easily
JavaScript
1
star
37

bdshare

A shell of bdshare.
JavaScript
1
star
38

react-digiclock

JavaScript
1
star
39

cookie-proxy

Graceful cookie API
JavaScript
1
star
40

SimpleRC4

Python
1
star