Git Product home page Git Product logo

pulltoload's Introduction

pulltoload

介绍

移动端上拉加载库,原生 JavaScript 实现。

效果演示:

https://mqyqingfeng.github.io/pulltoload/

https://mqyqingfeng.github.io/pulltoload/second.html

相关

下拉刷新库

依赖

原生 JavaScript 实现,无依赖。

大小

压缩后 3KB,gzip 压缩后更小。

下载

git clone git@github.com:mqyqingfeng/pulltoload.git

使用

<script src="path/pulltoload.js"></script>

或者

import PullToLoad from 'path/pulltoload.js'

示例

var pull = new PullToLoad("#main", {
    // 当滑动到距离底部还有 100px 的时候就触发加载事件
    threshold: 100,
    // 指定 loading 的 selector
    loader: '#loader'
})

// 绑定加载事件
pull.on("load", function(reset){
    setTimeout(function(){
        // 注意,当加载结束后,调用 reset 函数,以重置 loading
        reset()
    }, 1000)
})

API

初始化

var pulltoload = new PullToLoad(selector, options);

options

1.threshold

默认值为 100,表示当滑动到距离底部还有 100px 的时候就触发加载事件。

2.loader

默认值为 #loader,表示加载时的 loading 的选择符。

注意: loading 需要用户自己定义,然后在这里传入该 loading 元素的选择符。

事件绑定

pulltoload.on("load", function(reset) {
    // 模拟请求接口
    setTimeout(function() {
        // 注意,当加载结束后,调用 reset 函数,以重置 loading
        reset()
    }, 1000)
})

pulltoload's People

Contributors

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