+4
-2
@@ -197,3 +197,2 @@ <!DOCTYPE html> | ||
| }); | ||
| load.start(); | ||
| function loadMore() { | ||
@@ -216,3 +215,6 @@ // 请求接口 | ||
| } | ||
| load.$el.one('load-bottom', loadMore); | ||
| // 还能继续分页时,继续监听load-bottom 事件 | ||
| if (true) { | ||
| load.$el.one('load-bottom', loadMore); | ||
| } | ||
| }, 1000); | ||
@@ -219,0 +221,0 @@ } |
+2
-3
@@ -12,5 +12,4 @@ 'use strict' | ||
| }, options); | ||
| this.$main = _.isString(this.options.main) ? $(this.options.main) : this.options.main; | ||
| } | ||
| start() { | ||
| this.$main = _.isString(this.options.main) ? $(this.options.main) : this.options.main; | ||
| if (this.options.more) { | ||
@@ -17,0 +16,0 @@ this.$el.one('load-bottom',this.options.more); |
+5
-1
| { | ||
| "name": "mscroll", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "mScroll pull down refresh, pull up load more.", | ||
@@ -13,2 +13,6 @@ "devDependencies": { | ||
| }, | ||
| "keywords": [ | ||
| "pull down refresh", | ||
| "pull up load more" | ||
| ], | ||
| "author": { | ||
@@ -15,0 +19,0 @@ "name": "kangaoxiaoshi", |
+56
-32
| # mScroll -- pull down refresh and pull up load more. only use in Mobile devices | ||
| [](https://nodei.co/npm/mscroll/)<br/> | ||
| 1. pull down update | ||
| 1. pull up load more | ||
| #use document | ||
| ## install | ||
| ``` | ||
| npm install mScroll --save | ||
| npm install mscroll --save | ||
| ``` | ||
@@ -31,34 +30,59 @@ ## useage | ||
| var refresh = new Pull ('.js-content', { | ||
| msgElement: '.js-msgwrap', | ||
| msgs: ['下拉刷新.....', '释放刷新'], | ||
| distance: 10, | ||
| start: function () { | ||
| //console.info('start'); | ||
| }, | ||
| move: function () { | ||
| //console.info('move'); | ||
| }, | ||
| end: function () { | ||
| //console.info('end'); | ||
| }, | ||
| onRefresh: function () { | ||
| let ul = document.querySelector('.js-ul'); | ||
| let random = 1; | ||
| // after refresh do something you want | ||
| setTimeout(() => { | ||
| this.backTop(); | ||
| ul.innerHTML = ''; | ||
| for (let i = 0; i< 25; i++) { | ||
| random = (Math.random() * (20 - 1) + 1).toFixed(0); | ||
| ul.innerHTML +=`<li> | ||
| 我是刷新后内容${random} | ||
| </li>`; | ||
| } | ||
| }, 1000); | ||
| msgElement: '.js-msgwrap', | ||
| msgs: ['下拉刷新.....', '释放刷新'], | ||
| distance: 10, | ||
| start: function () { | ||
| //console.info('start'); | ||
| }, | ||
| move: function () { | ||
| //console.info('move'); | ||
| }, | ||
| end: function () { | ||
| //console.info('end'); | ||
| }, | ||
| onRefresh: function () { | ||
| let ul = document.querySelector('.js-ul'); | ||
| let random = 1; | ||
| // after refresh do something you want | ||
| setTimeout(() => { | ||
| this.backTop(); | ||
| ul.innerHTML = ''; | ||
| for (let i = 0; i< 25; i++) { | ||
| random = (Math.random() * (20 - 1) + 1).toFixed(0); | ||
| ul.innerHTML +=`<li> | ||
| 我是刷新后内容${random} | ||
| </li>`; | ||
| } | ||
| }); | ||
| }, 1000); | ||
| } | ||
| }); | ||
| ``` | ||
| * {msgElement} ``required`` selector or document.element where to place the refresh state message. | ||
| * {msgs} default ['下拉刷新.....', '释放刷新'] when pulling display msg. | ||
| * {distance} default 40px msgElement height. | ||
| * {start} ``function`` when start pull fire this function. | ||
| * {move} ``function`` when pulling fire this function. | ||
| * {end} ``function`` when finish pull fire this function. | ||
| * {onRefresh} ``function`` after pull do what you want in this function. | ||
| .more | ||
| ```js | ||
| var load = new More ('.js-content', { | ||
| main: '.js-content', | ||
| more: function () { | ||
| //load more function | ||
| console.log('load more'); | ||
| } | ||
| }); | ||
| ``` | ||
| * {.js-content} ``required`` part of ``main`` this.el is $('.js-content'). | ||
| ```js | ||
| this.$main.off('scroll').on('scroll', _.throttle((e) => { | ||
| if (this.el && this.el.getBoundingClientRect().bottom < document.body.clientHeight + 25) { | ||
| this.$el.trigger('load-bottom'); | ||
| } | ||
| }, 200)); | ||
| ``` | ||
| * {main} ``required`` selector or document.element which to add scroll. | ||
Sorry, the diff of this file is too big to display
102035
1.12%88
37.5%2015
-0.35%