├── docs ├── img │ ├── 1.jpg │ ├── 2.jpg │ └── 3.jpg ├── index.css ├── index.html ├── second.html ├── pulltoload.js └── normalize.css ├── README.md ├── pulltoload.min.js └── pulltoload.js /docs/img/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mqyqingfeng/pulltoload/HEAD/docs/img/1.jpg -------------------------------------------------------------------------------- /docs/img/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mqyqingfeng/pulltoload/HEAD/docs/img/2.jpg -------------------------------------------------------------------------------- /docs/img/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mqyqingfeng/pulltoload/HEAD/docs/img/3.jpg -------------------------------------------------------------------------------- /docs/index.css: -------------------------------------------------------------------------------- 1 | 2 | #main { 3 | overflow: auto; 4 | padding: 10px; 5 | } 6 | 7 | #main img { 8 | width: 100%; 9 | } 10 | 11 | #main p { 12 | margin-bottom: 0px; 13 | margin-top: 20px; 14 | } 15 | 16 | .loading { 17 | width: 150px; 18 | height: 10px; 19 | margin: 0 auto; 20 | margin-top: 20px; 21 | margin-bottom: 20px; 22 | } 23 | 24 | .loading span { 25 | display: inline-block; 26 | width: 10px; 27 | height: 100%; 28 | margin-right: 3px; 29 | border-radius: 50%; 30 | background: #e74c3c; 31 | -webkit-animation: load 1.04s ease infinite; 32 | } 33 | 34 | .loading span:last-child { 35 | margin-right: 0px; 36 | } 37 | 38 | @-webkit-keyframes load { 39 | 0% { 40 | opacity: 1; 41 | } 42 | 100% { 43 | opacity: 0; 44 | } 45 | } 46 | 47 | .loading span:nth-child(1) { 48 | -webkit-animation-delay: 0.13s; 49 | } 50 | 51 | .loading span:nth-child(2) { 52 | -webkit-animation-delay: 0.26s; 53 | } 54 | 55 | .loading span:nth-child(3) { 56 | -webkit-animation-delay: 0.39s; 57 | } 58 | 59 | .loading span:nth-child(4) { 60 | -webkit-animation-delay: 0.52s; 61 | } 62 | 63 | .loading span:nth-child(5) { 64 | -webkit-animation-delay: 0.65s; 65 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pulltoload 2 | 3 | ## 介绍 4 | 5 | 移动端上拉加载库,原生 JavaScript 实现。 6 | 7 | 效果演示: 8 | 9 | [https://mqyqingfeng.github.io/pulltoload/](https://mqyqingfeng.github.io/pulltoload/) 10 | 11 | [https://mqyqingfeng.github.io/pulltoload/second.html](https://mqyqingfeng.github.io/pulltoload/second.html) 12 | 13 | ## 相关 14 | 15 | [下拉刷新库](https://github.com/mqyqingfeng/pulltorefresh) 16 | 17 | ## 依赖 18 | 19 | 原生 JavaScript 实现,无依赖。 20 | 21 | ## 大小 22 | 23 | 压缩后 3KB,gzip 压缩后更小。 24 | 25 | ## 下载 26 | 27 | ```js 28 | git clone git@github.com:mqyqingfeng/pulltoload.git 29 | ``` 30 | 31 | ## 使用 32 | 33 | ```html 34 | 35 | ``` 36 | 37 | 或者 38 | 39 | ```js 40 | import PullToLoad from 'path/pulltoload.js' 41 | ``` 42 | 43 | ## 示例 44 | 45 | ```js 46 | var pull = new PullToLoad("#main", { 47 | // 当滑动到距离底部还有 100px 的时候就触发加载事件 48 | threshold: 100, 49 | // 指定 loading 的 selector 50 | loader: '#loader' 51 | }) 52 | 53 | // 绑定加载事件 54 | pull.on("load", function(reset){ 55 | setTimeout(function(){ 56 | // 注意,当加载结束后,调用 reset 函数,以重置 loading 57 | reset() 58 | }, 1000) 59 | }) 60 | ``` 61 | 62 | ## API 63 | 64 | ### 初始化 65 | 66 | ```js 67 | var pulltoload = new PullToLoad(selector, options); 68 | ``` 69 | 70 | ### options 71 | 72 | **1.threshold** 73 | 74 | 默认值为 `100`,表示当滑动到距离底部还有 100px 的时候就触发加载事件。 75 | 76 | **2.loader** 77 | 78 | 默认值为 `#loader`,表示加载时的 loading 的选择符。 79 | 80 | 注意: loading 需要用户自己定义,然后在这里传入该 loading 元素的选择符。 81 | 82 | ### 事件绑定 83 | 84 | ```js 85 | pulltoload.on("load", function(reset) { 86 | // 模拟请求接口 87 | setTimeout(function() { 88 | // 注意,当加载结束后,调用 reset 函数,以重置 loading 89 | reset() 90 | }, 1000) 91 | }) 92 | ``` 93 | -------------------------------------------------------------------------------- /pulltoload.min.js: -------------------------------------------------------------------------------- 1 | !function(){function e(){this.__events={}}function t(t,n){e.call(this),t.self===t||"body"==document.querySelector(t).tagName.toLowerCase()?(i=!0,this.element=window,this.container=document.body):this.container=this.element="string"==typeof t?document.querySelector(t):t,this.options=o.extend({},this.constructor.defaultOptions,n),this.init()}var n="object"==typeof self&&self.self==self&&self||"object"==typeof global&&global.global==global&&global||this||{},o={extend:function(e){for(var t=1,n=arguments.length;tdocument.documentElement.scrollHeight-this.options.threshold&&this.append()}:function(){this.element.scrollTop+this.element.clientHeight>this.element.scrollHeight-this.options.threshold&&this.append()}},s.append=function(){r||(r=!0,this._loader&&(this.element.self===this.element?document.body.append(this._loader):this.element.append(this._loader),this._loader.style.display="block"),this.emit("load",[this.reset.bind(this)]))},s.reset=function(){this._loader&&(this._loader.style.display="none"),r=!1},"undefined"==typeof exports||exports.nodeType?n.PullToLoad=t:("undefined"!=typeof module&&!module.nodeType&&module.exports&&(exports=module.exports=t),exports.PullToLoad=t)}(); -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 上拉加载更多 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |

模拟移动端后向上滑动

15 |

16 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 17 |

18 |

19 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 20 |

21 |

22 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 23 |

24 |

25 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 26 |

27 |

28 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 29 |

30 |

31 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 32 |

33 |

34 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 35 |

36 |

37 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 38 |

39 |

40 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 41 |

42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 |
50 | 51 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /docs/second.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 上拉加载更多 7 | 8 | 9 | 10 | 15 | 16 | 17 | 18 |
19 |

20 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 21 |

22 |

23 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 24 |

25 |

26 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 27 |

28 |

29 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 30 |

31 |

32 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 33 |

34 |

35 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 36 |

37 |

38 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 39 |

40 |

41 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 42 |

43 |

44 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic architecto quis necessitatibus rerum, ex ab deserunt impedit laboriosam, rem adipisci minima! Voluptates eum ducimus explicabo incidunt, eligendi! Dolores itaque, voluptate! 45 |

46 |
47 |
48 | 49 | 50 | 51 | 52 | 53 |
54 | 55 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /pulltoload.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var root = (typeof self == 'object' && self.self == self && self) || 3 | (typeof global == 'object' && global.global == global && global) || 4 | this || {}; 5 | 6 | var util = { 7 | extend: function(target) { 8 | for (var i = 1, len = arguments.length; i < len; i++) { 9 | for (var prop in arguments[i]) { 10 | if (arguments[i].hasOwnProperty(prop)) { 11 | target[prop] = arguments[i][prop] 12 | } 13 | } 14 | } 15 | 16 | return target 17 | }, 18 | isValidListener: function(listener) { 19 | if (typeof listener === 'function') { 20 | return true 21 | } else if (listener && typeof listener === 'object') { 22 | return util.isValidListener(listener.listener) 23 | } else { 24 | return false 25 | } 26 | }, 27 | indexOf: function(array, item) { 28 | if (array.indexOf) { 29 | return array.indexOf(item); 30 | } else { 31 | var result = -1; 32 | for (var i = 0, len = array.length; i < len; i++) { 33 | if (array[i] === item) { 34 | result = i; 35 | break; 36 | } 37 | } 38 | return result; 39 | } 40 | } 41 | }; 42 | 43 | function EventEmitter() { 44 | this.__events = {} 45 | } 46 | 47 | EventEmitter.prototype.on = function(eventName, listener) { 48 | if (!eventName || !listener) return; 49 | 50 | if (!util.isValidListener(listener)) { 51 | throw new TypeError('listener must be a function'); 52 | } 53 | 54 | var events = this.__events; 55 | var listeners = events[eventName] = events[eventName] || []; 56 | var listenerIsWrapped = typeof listener === 'object'; 57 | 58 | // 不重复添加事件 59 | if (util.indexOf(listeners, listener) === -1) { 60 | listeners.push(listenerIsWrapped ? listener : { 61 | listener: listener, 62 | once: false 63 | }); 64 | } 65 | 66 | return this; 67 | }; 68 | 69 | EventEmitter.prototype.once = function(eventName, listener) { 70 | return this.on(eventName, { 71 | listener: listener, 72 | once: true 73 | }) 74 | }; 75 | 76 | EventEmitter.prototype.off = function(eventName, listener) { 77 | var listeners = this.__events[eventName]; 78 | if (!listeners) return; 79 | 80 | var index; 81 | for (var i = 0, len = listeners.length; i < len; i++) { 82 | if (listeners[i] && listeners[i].listener === listener) { 83 | index = i; 84 | break; 85 | } 86 | } 87 | 88 | if (typeof index !== 'undefined') { 89 | listeners.splice(index, 1, null) 90 | } 91 | 92 | return this; 93 | }; 94 | 95 | EventEmitter.prototype.emit = function(eventName, args) { 96 | var listeners = this.__events[eventName]; 97 | if (!listeners) return; 98 | 99 | for (var i = 0; i < listeners.length; i++) { 100 | var listener = listeners[i]; 101 | if (listener) { 102 | listener.listener.apply(this, args || []); 103 | if (listener.once) { 104 | this.off(eventName, listener.listener) 105 | } 106 | } 107 | 108 | } 109 | 110 | return this; 111 | 112 | }; 113 | 114 | var isWindow = false; 115 | 116 | function PullToLoad(selector, options) { 117 | 118 | EventEmitter.call(this); 119 | if (selector.self === selector || document.querySelector(selector).tagName.toLowerCase() == 'body') { 120 | isWindow = true; 121 | this.element = window; 122 | this.container = document.body; 123 | } else { 124 | this.container = this.element = typeof selector === "string" ? document.querySelector(selector) : selector; 125 | } 126 | 127 | this.options = util.extend({}, this.constructor.defaultOptions, options); 128 | 129 | this.init(); 130 | } 131 | 132 | PullToLoad.VERSION = '1.0.0'; 133 | 134 | PullToLoad.defaultOptions = { 135 | threshold: 100, 136 | loader: "#loader" 137 | } 138 | 139 | var proto = PullToLoad.prototype = new EventEmitter(); 140 | 141 | proto.constructor = PullToLoad; 142 | 143 | proto.init = function() { 144 | this.setLoader(); 145 | this.onscroll(); 146 | this.bindEvent(); 147 | }; 148 | 149 | proto.setLoader = function() { 150 | var _loader = typeof this.options.loader === "string" ? document.querySelector(this.options.loader) : this.options.loader; 151 | if (_loader) { 152 | _loader.style.display = 'none'; 153 | this._loader = _loader; 154 | } 155 | }; 156 | 157 | proto.bindEvent = function() { 158 | this.element.addEventListener('scroll', this); 159 | }; 160 | 161 | proto.handleEvent = function(event) { 162 | var method = 'on' + event.type; 163 | if (this[method]) { 164 | this[method](event); 165 | } 166 | }; 167 | 168 | var loading = false; 169 | 170 | // http://www.w3help.org/zh-cn/causes/SD9013 171 | proto.onscroll = function() { 172 | 173 | if (isWindow) { 174 | 175 | this.onscroll = function() { 176 | var scrollTop = window.pageYOffset || document.documentElement.scrollTop; 177 | var viewPortHeight = window.innerHeight || document.documentElement.clientHeight; 178 | var docHeight = document.documentElement.scrollHeight; 179 | 180 | if (scrollTop + viewPortHeight > docHeight - this.options.threshold) { 181 | this.append() 182 | } 183 | } 184 | 185 | } else { 186 | 187 | this.onscroll = function() { 188 | if (this.element.scrollTop + this.element.clientHeight > this.element.scrollHeight - this.options.threshold) { 189 | this.append() 190 | } 191 | } 192 | 193 | } 194 | 195 | }; 196 | 197 | proto.append = function() { 198 | if (loading) return; 199 | 200 | loading = true; 201 | 202 | if (this._loader) { 203 | if (this.element.self === this.element) { 204 | document.body.append(this._loader) 205 | } else { 206 | this.element.append(this._loader) 207 | 208 | } 209 | this._loader.style.display = 'block'; 210 | } 211 | 212 | this.emit("load", [this.reset.bind(this)]) 213 | 214 | }; 215 | 216 | proto.reset = function() { 217 | if (this._loader) { 218 | this._loader.style.display = 'none'; 219 | } 220 | 221 | loading = false; 222 | }; 223 | 224 | if (typeof exports != 'undefined' && !exports.nodeType) { 225 | if (typeof module != 'undefined' && !module.nodeType && module.exports) { 226 | exports = module.exports = PullToLoad; 227 | } 228 | exports.PullToLoad = PullToLoad; 229 | } else { 230 | root.PullToLoad = PullToLoad; 231 | } 232 | 233 | }()); -------------------------------------------------------------------------------- /docs/pulltoload.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var root = (typeof self == 'object' && self.self == self && self) || 3 | (typeof global == 'object' && global.global == global && global) || 4 | this || {}; 5 | 6 | var util = { 7 | extend: function(target) { 8 | for (var i = 1, len = arguments.length; i < len; i++) { 9 | for (var prop in arguments[i]) { 10 | if (arguments[i].hasOwnProperty(prop)) { 11 | target[prop] = arguments[i][prop] 12 | } 13 | } 14 | } 15 | 16 | return target 17 | }, 18 | isValidListener: function(listener) { 19 | if (typeof listener === 'function') { 20 | return true 21 | } else if (listener && typeof listener === 'object') { 22 | return util.isValidListener(listener.listener) 23 | } else { 24 | return false 25 | } 26 | }, 27 | indexOf: function(array, item) { 28 | if (array.indexOf) { 29 | return array.indexOf(item); 30 | } else { 31 | var result = -1; 32 | for (var i = 0, len = array.length; i < len; i++) { 33 | if (array[i] === item) { 34 | result = i; 35 | break; 36 | } 37 | } 38 | return result; 39 | } 40 | } 41 | }; 42 | 43 | function EventEmitter() { 44 | this.__events = {} 45 | } 46 | 47 | EventEmitter.prototype.on = function(eventName, listener) { 48 | if (!eventName || !listener) return; 49 | 50 | if (!util.isValidListener(listener)) { 51 | throw new TypeError('listener must be a function'); 52 | } 53 | 54 | var events = this.__events; 55 | var listeners = events[eventName] = events[eventName] || []; 56 | var listenerIsWrapped = typeof listener === 'object'; 57 | 58 | // 不重复添加事件 59 | if (util.indexOf(listeners, listener) === -1) { 60 | listeners.push(listenerIsWrapped ? listener : { 61 | listener: listener, 62 | once: false 63 | }); 64 | } 65 | 66 | return this; 67 | }; 68 | 69 | EventEmitter.prototype.once = function(eventName, listener) { 70 | return this.on(eventName, { 71 | listener: listener, 72 | once: true 73 | }) 74 | }; 75 | 76 | EventEmitter.prototype.off = function(eventName, listener) { 77 | var listeners = this.__events[eventName]; 78 | if (!listeners) return; 79 | 80 | var index; 81 | for (var i = 0, len = listeners.length; i < len; i++) { 82 | if (listeners[i] && listeners[i].listener === listener) { 83 | index = i; 84 | break; 85 | } 86 | } 87 | 88 | if (typeof index !== 'undefined') { 89 | listeners.splice(index, 1, null) 90 | } 91 | 92 | return this; 93 | }; 94 | 95 | EventEmitter.prototype.emit = function(eventName, args) { 96 | var listeners = this.__events[eventName]; 97 | if (!listeners) return; 98 | 99 | for (var i = 0; i < listeners.length; i++) { 100 | var listener = listeners[i]; 101 | if (listener) { 102 | listener.listener.apply(this, args || []); 103 | if (listener.once) { 104 | this.off(eventName, listener.listener) 105 | } 106 | } 107 | 108 | } 109 | 110 | return this; 111 | 112 | }; 113 | 114 | var isWindow = false; 115 | 116 | function PullToLoad(selector, options) { 117 | 118 | EventEmitter.call(this); 119 | if (selector.self === selector || document.querySelector(selector).tagName.toLowerCase() == 'body') { 120 | isWindow = true; 121 | this.element = window; 122 | this.container = document.body; 123 | } else { 124 | this.container = this.element = typeof selector === "string" ? document.querySelector(selector) : selector; 125 | } 126 | 127 | this.options = util.extend({}, this.constructor.defaultOptions, options); 128 | 129 | this.init(); 130 | } 131 | 132 | PullToLoad.VERSION = '1.0.0'; 133 | 134 | PullToLoad.defaultOptions = { 135 | threshold: 100, 136 | loader: "#loader" 137 | } 138 | 139 | var proto = PullToLoad.prototype = new EventEmitter(); 140 | 141 | proto.constructor = PullToLoad; 142 | 143 | proto.init = function() { 144 | this.setLoader(); 145 | this.onscroll(); 146 | this.bindEvent(); 147 | }; 148 | 149 | proto.setLoader = function() { 150 | var _loader = typeof this.options.loader === "string" ? document.querySelector(this.options.loader) : this.options.loader; 151 | if (_loader) { 152 | _loader.style.display = 'none'; 153 | this._loader = _loader; 154 | } 155 | }; 156 | 157 | proto.bindEvent = function() { 158 | this.element.addEventListener('scroll', this); 159 | }; 160 | 161 | proto.handleEvent = function(event) { 162 | var method = 'on' + event.type; 163 | if (this[method]) { 164 | this[method](event); 165 | } 166 | }; 167 | 168 | var loading = false; 169 | 170 | // http://www.w3help.org/zh-cn/causes/SD9013 171 | proto.onscroll = function() { 172 | 173 | if (isWindow) { 174 | 175 | this.onscroll = function() { 176 | var scrollTop = window.pageYOffset || document.documentElement.scrollTop; 177 | var viewPortHeight = window.innerHeight || document.documentElement.clientHeight; 178 | var docHeight = document.documentElement.scrollHeight; 179 | 180 | if (scrollTop + viewPortHeight > docHeight - this.options.threshold) { 181 | this.append() 182 | } 183 | } 184 | 185 | } else { 186 | 187 | this.onscroll = function() { 188 | if (this.element.scrollTop + this.element.clientHeight > this.element.scrollHeight - this.options.threshold) { 189 | this.append() 190 | } 191 | } 192 | 193 | } 194 | 195 | }; 196 | 197 | proto.append = function() { 198 | if (loading) return; 199 | 200 | loading = true; 201 | 202 | if (this._loader) { 203 | if (this.element.self === this.element) { 204 | document.body.append(this._loader) 205 | } else { 206 | this.element.append(this._loader) 207 | 208 | } 209 | this._loader.style.display = 'block'; 210 | } 211 | 212 | this.emit("load", [this.reset.bind(this)]) 213 | 214 | }; 215 | 216 | proto.reset = function() { 217 | if (this._loader) { 218 | this._loader.style.display = 'none'; 219 | } 220 | 221 | loading = false; 222 | }; 223 | 224 | if (typeof exports != 'undefined' && !exports.nodeType) { 225 | if (typeof module != 'undefined' && !module.nodeType && module.exports) { 226 | exports = module.exports = PullToLoad; 227 | } 228 | exports.PullToLoad = PullToLoad; 229 | } else { 230 | root.PullToLoad = PullToLoad; 231 | } 232 | 233 | }()); -------------------------------------------------------------------------------- /docs/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */ 2 | 3 | /* Document 4 | ========================================================================== */ 5 | 6 | /** 7 | * 1. Correct the line height in all browsers. 8 | * 2. Prevent adjustments of font size after orientation changes in 9 | * IE on Windows Phone and in iOS. 10 | */ 11 | 12 | html { 13 | line-height: 1.15; /* 1 */ 14 | -ms-text-size-adjust: 100%; /* 2 */ 15 | -webkit-text-size-adjust: 100%; /* 2 */ 16 | } 17 | 18 | /* Sections 19 | ========================================================================== */ 20 | 21 | /** 22 | * Remove the margin in all browsers (opinionated). 23 | */ 24 | 25 | body { 26 | margin: 0; 27 | } 28 | 29 | /** 30 | * Add the correct display in IE 9-. 31 | */ 32 | 33 | article, 34 | aside, 35 | footer, 36 | header, 37 | nav, 38 | section { 39 | display: block; 40 | } 41 | 42 | /** 43 | * Correct the font size and margin on `h1` elements within `section` and 44 | * `article` contexts in Chrome, Firefox, and Safari. 45 | */ 46 | 47 | h1 { 48 | font-size: 2em; 49 | margin: 0.67em 0; 50 | } 51 | 52 | /* Grouping content 53 | ========================================================================== */ 54 | 55 | /** 56 | * Add the correct display in IE 9-. 57 | * 1. Add the correct display in IE. 58 | */ 59 | 60 | figcaption, 61 | figure, 62 | main { /* 1 */ 63 | display: block; 64 | } 65 | 66 | /** 67 | * Add the correct margin in IE 8. 68 | */ 69 | 70 | figure { 71 | margin: 1em 40px; 72 | } 73 | 74 | /** 75 | * 1. Add the correct box sizing in Firefox. 76 | * 2. Show the overflow in Edge and IE. 77 | */ 78 | 79 | hr { 80 | box-sizing: content-box; /* 1 */ 81 | height: 0; /* 1 */ 82 | overflow: visible; /* 2 */ 83 | } 84 | 85 | /** 86 | * 1. Correct the inheritance and scaling of font size in all browsers. 87 | * 2. Correct the odd `em` font sizing in all browsers. 88 | */ 89 | 90 | pre { 91 | font-family: monospace, monospace; /* 1 */ 92 | font-size: 1em; /* 2 */ 93 | } 94 | 95 | /* Text-level semantics 96 | ========================================================================== */ 97 | 98 | /** 99 | * 1. Remove the gray background on active links in IE 10. 100 | * 2. Remove gaps in links underline in iOS 8+ and Safari 8+. 101 | */ 102 | 103 | a { 104 | background-color: transparent; /* 1 */ 105 | -webkit-text-decoration-skip: objects; /* 2 */ 106 | } 107 | 108 | /** 109 | * 1. Remove the bottom border in Chrome 57- and Firefox 39-. 110 | * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. 111 | */ 112 | 113 | abbr[title] { 114 | border-bottom: none; /* 1 */ 115 | text-decoration: underline; /* 2 */ 116 | text-decoration: underline dotted; /* 2 */ 117 | } 118 | 119 | /** 120 | * Prevent the duplicate application of `bolder` by the next rule in Safari 6. 121 | */ 122 | 123 | b, 124 | strong { 125 | font-weight: inherit; 126 | } 127 | 128 | /** 129 | * Add the correct font weight in Chrome, Edge, and Safari. 130 | */ 131 | 132 | b, 133 | strong { 134 | font-weight: bolder; 135 | } 136 | 137 | /** 138 | * 1. Correct the inheritance and scaling of font size in all browsers. 139 | * 2. Correct the odd `em` font sizing in all browsers. 140 | */ 141 | 142 | code, 143 | kbd, 144 | samp { 145 | font-family: monospace, monospace; /* 1 */ 146 | font-size: 1em; /* 2 */ 147 | } 148 | 149 | /** 150 | * Add the correct font style in Android 4.3-. 151 | */ 152 | 153 | dfn { 154 | font-style: italic; 155 | } 156 | 157 | /** 158 | * Add the correct background and color in IE 9-. 159 | */ 160 | 161 | mark { 162 | background-color: #ff0; 163 | color: #000; 164 | } 165 | 166 | /** 167 | * Add the correct font size in all browsers. 168 | */ 169 | 170 | small { 171 | font-size: 80%; 172 | } 173 | 174 | /** 175 | * Prevent `sub` and `sup` elements from affecting the line height in 176 | * all browsers. 177 | */ 178 | 179 | sub, 180 | sup { 181 | font-size: 75%; 182 | line-height: 0; 183 | position: relative; 184 | vertical-align: baseline; 185 | } 186 | 187 | sub { 188 | bottom: -0.25em; 189 | } 190 | 191 | sup { 192 | top: -0.5em; 193 | } 194 | 195 | /* Embedded content 196 | ========================================================================== */ 197 | 198 | /** 199 | * Add the correct display in IE 9-. 200 | */ 201 | 202 | audio, 203 | video { 204 | display: inline-block; 205 | } 206 | 207 | /** 208 | * Add the correct display in iOS 4-7. 209 | */ 210 | 211 | audio:not([controls]) { 212 | display: none; 213 | height: 0; 214 | } 215 | 216 | /** 217 | * Remove the border on images inside links in IE 10-. 218 | */ 219 | 220 | img { 221 | border-style: none; 222 | } 223 | 224 | /** 225 | * Hide the overflow in IE. 226 | */ 227 | 228 | svg:not(:root) { 229 | overflow: hidden; 230 | } 231 | 232 | /* Forms 233 | ========================================================================== */ 234 | 235 | /** 236 | * 1. Change the font styles in all browsers (opinionated). 237 | * 2. Remove the margin in Firefox and Safari. 238 | */ 239 | 240 | button, 241 | input, 242 | optgroup, 243 | select, 244 | textarea { 245 | font-family: sans-serif; /* 1 */ 246 | font-size: 100%; /* 1 */ 247 | line-height: 1.15; /* 1 */ 248 | margin: 0; /* 2 */ 249 | } 250 | 251 | /** 252 | * Show the overflow in IE. 253 | * 1. Show the overflow in Edge. 254 | */ 255 | 256 | button, 257 | input { /* 1 */ 258 | overflow: visible; 259 | } 260 | 261 | /** 262 | * Remove the inheritance of text transform in Edge, Firefox, and IE. 263 | * 1. Remove the inheritance of text transform in Firefox. 264 | */ 265 | 266 | button, 267 | select { /* 1 */ 268 | text-transform: none; 269 | } 270 | 271 | /** 272 | * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video` 273 | * controls in Android 4. 274 | * 2. Correct the inability to style clickable types in iOS and Safari. 275 | */ 276 | 277 | button, 278 | html [type="button"], /* 1 */ 279 | [type="reset"], 280 | [type="submit"] { 281 | -webkit-appearance: button; /* 2 */ 282 | } 283 | 284 | /** 285 | * Remove the inner border and padding in Firefox. 286 | */ 287 | 288 | button::-moz-focus-inner, 289 | [type="button"]::-moz-focus-inner, 290 | [type="reset"]::-moz-focus-inner, 291 | [type="submit"]::-moz-focus-inner { 292 | border-style: none; 293 | padding: 0; 294 | } 295 | 296 | /** 297 | * Restore the focus styles unset by the previous rule. 298 | */ 299 | 300 | button:-moz-focusring, 301 | [type="button"]:-moz-focusring, 302 | [type="reset"]:-moz-focusring, 303 | [type="submit"]:-moz-focusring { 304 | outline: 1px dotted ButtonText; 305 | } 306 | 307 | /** 308 | * Correct the padding in Firefox. 309 | */ 310 | 311 | fieldset { 312 | padding: 0.35em 0.75em 0.625em; 313 | } 314 | 315 | /** 316 | * 1. Correct the text wrapping in Edge and IE. 317 | * 2. Correct the color inheritance from `fieldset` elements in IE. 318 | * 3. Remove the padding so developers are not caught out when they zero out 319 | * `fieldset` elements in all browsers. 320 | */ 321 | 322 | legend { 323 | box-sizing: border-box; /* 1 */ 324 | color: inherit; /* 2 */ 325 | display: table; /* 1 */ 326 | max-width: 100%; /* 1 */ 327 | padding: 0; /* 3 */ 328 | white-space: normal; /* 1 */ 329 | } 330 | 331 | /** 332 | * 1. Add the correct display in IE 9-. 333 | * 2. Add the correct vertical alignment in Chrome, Firefox, and Opera. 334 | */ 335 | 336 | progress { 337 | display: inline-block; /* 1 */ 338 | vertical-align: baseline; /* 2 */ 339 | } 340 | 341 | /** 342 | * Remove the default vertical scrollbar in IE. 343 | */ 344 | 345 | textarea { 346 | overflow: auto; 347 | } 348 | 349 | /** 350 | * 1. Add the correct box sizing in IE 10-. 351 | * 2. Remove the padding in IE 10-. 352 | */ 353 | 354 | [type="checkbox"], 355 | [type="radio"] { 356 | box-sizing: border-box; /* 1 */ 357 | padding: 0; /* 2 */ 358 | } 359 | 360 | /** 361 | * Correct the cursor style of increment and decrement buttons in Chrome. 362 | */ 363 | 364 | [type="number"]::-webkit-inner-spin-button, 365 | [type="number"]::-webkit-outer-spin-button { 366 | height: auto; 367 | } 368 | 369 | /** 370 | * 1. Correct the odd appearance in Chrome and Safari. 371 | * 2. Correct the outline style in Safari. 372 | */ 373 | 374 | [type="search"] { 375 | -webkit-appearance: textfield; /* 1 */ 376 | outline-offset: -2px; /* 2 */ 377 | } 378 | 379 | /** 380 | * Remove the inner padding and cancel buttons in Chrome and Safari on macOS. 381 | */ 382 | 383 | [type="search"]::-webkit-search-cancel-button, 384 | [type="search"]::-webkit-search-decoration { 385 | -webkit-appearance: none; 386 | } 387 | 388 | /** 389 | * 1. Correct the inability to style clickable types in iOS and Safari. 390 | * 2. Change font properties to `inherit` in Safari. 391 | */ 392 | 393 | ::-webkit-file-upload-button { 394 | -webkit-appearance: button; /* 1 */ 395 | font: inherit; /* 2 */ 396 | } 397 | 398 | /* Interactive 399 | ========================================================================== */ 400 | 401 | /* 402 | * Add the correct display in IE 9-. 403 | * 1. Add the correct display in Edge, IE, and Firefox. 404 | */ 405 | 406 | details, /* 1 */ 407 | menu { 408 | display: block; 409 | } 410 | 411 | /* 412 | * Add the correct display in all browsers. 413 | */ 414 | 415 | summary { 416 | display: list-item; 417 | } 418 | 419 | /* Scripting 420 | ========================================================================== */ 421 | 422 | /** 423 | * Add the correct display in IE 9-. 424 | */ 425 | 426 | canvas { 427 | display: inline-block; 428 | } 429 | 430 | /** 431 | * Add the correct display in IE. 432 | */ 433 | 434 | template { 435 | display: none; 436 | } 437 | 438 | /* Hidden 439 | ========================================================================== */ 440 | 441 | /** 442 | * Add the correct display in IE 10-. 443 | */ 444 | 445 | [hidden] { 446 | display: none; 447 | } 448 | --------------------------------------------------------------------------------