Coder Social home page Coder Social logo

preventoverscrolljs's Introduction

preventoverscrolljs

使用

页面布局

<body id="wrapper">
    <div id="container"></div>
</body>

引用组件

引用组件支持下面两种方式:

  • clone之后直接拷贝引用bin文件夹下面的preventoverscroll.min.js
  • 从npm下载安装
    • npm install --save preventoverscrolljs
    • var PreventOverScroll = require('preventoverscrolljs');

设置样式

不少人反馈用了这个组件之后不能滑动,其实是样式没有写好。 按照上面的布局,你的样式应该包含下面这段:

    html, body {
        width: 100%;
        height: 100%;
    }
    #container {
        height: 100%;
    }

实例化组件

var list = ['container'];
var prevent = new PreventOverScroll({
    list: list
});

区分安卓和IOS

因为安卓不支持原生的橡皮筋效果,而且安卓在div内的滑动效果很差,所以上述组件应该这样实例化:

var outer = (  isAndroid // do it yourself
             ? 'wrapper'
             : 'container' );
var list = [outer];
var prevent = new PreventOverScroll({
    list: list
});

TODO

上面的实例化过程很愚笨,不够智能,还需要完善,但不马上完善一定是因为要考虑足够多的应用场景。

preventoverscrolljs's People

Contributors

yuanzm avatar tongjun741 avatar

Watchers

James Cloos 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.