@beeapi/nutui
Version:
一套轻量级移动端Vue组件库
7 lines • 5.54 kB
JavaScript
/*!
* @beeapi/nutui v2.2.10 - infiniteloading.js, 451ed2404bee284b891e, Sat Dec 19 2020 12:06:10 GMT+0800 (中国标准时间)
* (c) 2017-2020 JDC
* Released under the MIT License.
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("infiniteloading",[],t):"object"==typeof exports?exports.infiniteloading=t():e.infiniteloading=t()}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="./",n(n.s=179)}({0:function(e,t,n){"use strict";function o(e,t,n,o,i,r,s,l){var a,u="function"==typeof e?e.options:e;if(t&&(u.render=t,u.staticRenderFns=n,u._compiled=!0),o&&(u.functional=!0),r&&(u._scopeId="data-v-"+r),s?(a=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},u._ssrRegister=a):i&&(a=l?function(){i.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:i),a)if(u.functional){u._injectStyles=a;var c=u.render;u.render=function(e,t){return a.call(t),c(e,t)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,a):[a]}return{exports:e,options:u}}n.d(t,"a",(function(){return o}))},119:function(e,t,n){},179:function(e,t,n){"use strict";n.r(t);var o={name:"nut-infiniteloading",props:{hasMore:{type:Boolean,default:!0},isLoading:{type:Boolean,default:!1},threshold:{type:Number,default:200},useWindow:{type:Boolean,default:!0},useCapture:{type:Boolean,default:!1},isShowMod:{type:Boolean,default:!1},unloadMoreTxt:{type:String,default:"哎呀,这里是底部了啦"},scrollChange:{type:Function}},data:function(){return{startX:0,startY:0,diffX:0,diffY:0,beforeScrollTop:0}},mounted:function(){var e=this.getParentElement(this.$el),t=window;!1===this.useWindow&&(t=e),this.scrollEl=t,this.scrollListener()},methods:{touchStartHandle:function(e){try{this.startX=Number(e.changedTouches[0].pageX),this.startY=Number(e.changedTouches[0].pageY)}catch(e){console.log(e.message)}},touchMoveHandle:function(e){var t=Number(e.changedTouches[0].pageX),n=Number(e.changedTouches[0].pageY);this.diffX=t-this.startX,this.diffY=n-this.startY},getParentElement:function(e){return e&&e.parentNode},scrollListener:function(){this.scrollEl.addEventListener("scroll",this.handleScroll,this.useCapture),window.addEventListener("resize",this.handleScroll,this.useCapture)},requestAniFrame:function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}},handleScroll:function(){var e=this;this.requestAniFrame()((function(){if(!e.isScrollAtBottom()||!e.hasMore||e.isLoading||!e.isShowMod)return!1;e.$emit("loadmore")}))},calculateTopPosition:function(e){return e?e.offsetTop+this.calculateTopPosition(e.offsetParent):0},getWindowScrollTop:function(){return void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop},isScrollAtBottom:function(){var e,t=0,n=this.getWindowScrollTop();if(this.useWindow)e=this.calculateTopPosition(this.$refs.scroller)+this.$refs.scroller.offsetHeight-n-window.innerHeight;else{var o=this.scrollEl,i=o.scrollHeight,r=o.clientHeight,s=o.scrollTop;e=i-r-s,t=s}this.$emit("scrollChange",this.useWindow?n:t);this.beforeScrollTop;return this.beforeScrollTop=n,e<=this.threshold&&n>=this.beforeScrollTop}},activated:function(){this.keepAlive&&(this.keepAlive=!1,this.scrollListener())},deactivated:function(){this.keepAlive=!0,this.scrollEl.removeEventListener("scroll",this.handleScroll,this.useCapture),window.removeEventListener("resize",this.handleScroll,this.useCapture)},destroyed:function(){this.scrollEl.removeEventListener("scroll",this.handleScroll,this.useCapture),window.removeEventListener("resize",this.handleScroll,this.useCapture)}},i=n(0),r=Object(i.a)(o,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"scroller",staticClass:"nut-infiniteloading",on:{touchstart:function(t){return e.touchStartHandle(t)},touchmove:function(t){return e.touchMoveHandle(t)}}},[e._t("default"),e._v(" "),n("div",{staticClass:"load-more"},[n("div",{staticClass:"bottom-tips"},[e.isLoading?[n("i",{staticClass:"loading-hint"}),n("span",{staticClass:"loading-txt"},[e._v("加载中...")])]:e.hasMore?e._e():n("span",{staticClass:"tips-txt"},[e._v(e._s(e.unloadMoreTxt))])],2)])],2)}),[],!1,null,null,null).exports;n(119);r.install=function(e){e.component(r.name,r)};t.default=r}})}));
//# sourceMappingURL=infiniteloading.js.map