UNPKG

infinite-loading

Version:

vue-infinite-loading based on bedlate's vue-data-loading

1 lines 11.1 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("VueDataLoading",[],e):"object"==typeof exports?exports.VueDataLoading=e():t.VueDataLoading=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1);"undefined"!=typeof window&&window.Vue&&window.Vue.component("vue-data-loading",i.a),e.default=i.a},function(t,e,n){"use strict";function i(t){n(2)}var o=n(8),a=n(9),s=n(7),r=i,l=s(o.a,a.a,!1,r,null,null);e.a=l.exports},function(t,e,n){var i=n(3);"string"==typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);n(5)("7baaf2ce",i,!0)},function(t,e,n){e=t.exports=n(4)(!1),e.push([t.i,"\n.vue-data-loading .loading-header, .vue-data-loading .loading-footer {\n position: relative;\n text-align: center;\n font-size: 30px;\n color: #999999;\n}\n.vue-data-loading .loading-header .header-text, .vue-data-loading .loading-header .footer-text, .vue-data-loading .loading-footer .header-text, .vue-data-loading .loading-footer .footer-text {\n width: 100%;\n position: absolute;\n}\n.vue-data-loading .loading-header .header-text, .vue-data-loading .loading-footer .header-text {\n bottom: 20px;\n}\n.vue-data-loading .loading-header .footer-text, .vue-data-loading .loading-footer .footer-text {\n padding: 20px 0 40px 0;\n}\n",""])},function(t,e){function n(t,e){var n=t[1]||"",o=t[3];if(!o)return n;if(e&&"function"==typeof btoa){var a=i(o);return[n].concat(o.sources.map(function(t){return"/*# sourceURL="+o.sourceRoot+t+" */"})).concat([a]).join("\n")}return[n].join("\n")}function i(t){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(t))))+" */"}t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var i=n(e,t);return e[2]?"@media "+e[2]+"{"+i+"}":i}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var i={},o=0;o<this.length;o++){var a=this[o][0];"number"==typeof a&&(i[a]=!0)}for(o=0;o<t.length;o++){var s=t[o];"number"==typeof s[0]&&i[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="("+s[2]+") and ("+n+")"),e.push(s))}},e}},function(t,e,n){function i(t){for(var e=0;e<t.length;e++){var n=t[e],i=u[n.id];if(i){i.refs++;for(var o=0;o<i.parts.length;o++)i.parts[o](n.parts[o]);for(;o<n.parts.length;o++)i.parts.push(a(n.parts[o]));i.parts.length>n.parts.length&&(i.parts.length=n.parts.length)}else{for(var s=[],o=0;o<n.parts.length;o++)s.push(a(n.parts[o]));u[n.id]={id:n.id,refs:1,parts:s}}}}function o(){var t=document.createElement("style");return t.type="text/css",c.appendChild(t),t}function a(t){var e,n,i=document.querySelector('style[data-vue-ssr-id~="'+t.id+'"]');if(i){if(f)return v;i.parentNode.removeChild(i)}if(g){var a=h++;i=p||(p=o()),e=s.bind(null,i,a,!1),n=s.bind(null,i,a,!0)}else i=o(),e=r.bind(null,i),n=function(){i.parentNode.removeChild(i)};return e(t),function(i){if(i){if(i.css===t.css&&i.media===t.media&&i.sourceMap===t.sourceMap)return;e(t=i)}else n()}}function s(t,e,n,i){var o=n?"":i.css;if(t.styleSheet)t.styleSheet.cssText=_(e,o);else{var a=document.createTextNode(o),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(a,s[e]):t.appendChild(a)}}function r(t,e){var n=e.css,i=e.media,o=e.sourceMap;if(i&&t.setAttribute("media",i),o&&(n+="\n/*# sourceURL="+o.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}var l="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!l)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var d=n(6),u={},c=l&&(document.head||document.getElementsByTagName("head")[0]),p=null,h=0,f=!1,v=function(){},g="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());t.exports=function(t,e,n){f=n;var o=d(t,e);return i(o),function(e){for(var n=[],a=0;a<o.length;a++){var s=o[a],r=u[s.id];r.refs--,n.push(r)}e?(o=d(t,e),i(o)):o=[];for(var a=0;a<n.length;a++){var r=n[a];if(0===r.refs){for(var l=0;l<r.parts.length;l++)r.parts[l]();delete u[r.id]}}}};var _=function(){var t=[];return function(e,n){return t[e]=n,t.filter(Boolean).join("\n")}}()},function(t,e){t.exports=function(t,e){for(var n=[],i={},o=0;o<e.length;o++){var a=e[o],s=a[0],r=a[1],l=a[2],d=a[3],u={id:t+":"+o,css:r,media:l,sourceMap:d};i[s]?i[s].parts.push(u):n.push(i[s]={id:s,parts:[u]})}return n}},function(t,e){t.exports=function(t,e,n,i,o,a){var s,r=t=t||{},l=typeof t.default;"object"!==l&&"function"!==l||(s=t,r=t.default);var d="function"==typeof r?r.options:r;e&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0),n&&(d.functional=!0),o&&(d._scopeId=o);var u;if(a?(u=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},d._ssrRegister=u):i&&(u=i),u){var c=d.functional,p=c?d.render:d.beforeCreate;c?(d._injectStyles=u,d.render=function(t,e){return u.call(e),p(t,e)}):d.beforeCreate=p?[].concat(p,u):[u]}return{esModule:s,exports:r,options:d}}},function(t,e,n){"use strict";e.a={props:{loading:{type:Boolean,default:!1},completed:{type:Boolean,default:!1},distance:{type:Number,default:60},offset:{type:Number,default:0},listens:{type:Array,default:function(){return["infinite-scroll","pull-down","pull-up"]}},container:{type:String},initScroll:{type:Boolean,default:!1},pulldown:{type:Boolean,default:!1},showFooter:{type:Boolean,default:!0}},data:function(){return{margin:{top:0,bottom:0},pull:{from:-1,to:-1,distance:0,type:null,available:!1},loadingType:null,PULL_UP:"pull-up",PULL_DOWN:"pull-down",INFINITE_SCROLL:"infinite-scroll"}},computed:{_container:function(){return this.container?this.$parent.$refs[this.container]:window.window},pullHeight:function(){return this.pull.distance>this.distance?this.distance:this.pull.distance}},watch:{loading:function(t,e){e&&!t&&(this.resetPull(),this.setLoadingType())}},methods:{updateView:function(){var t=this.$el.getBoundingClientRect(),e=t.top,n=t.height;this.margin={top:e,bottom:window.innerHeight-(n+e+this.offset)}},setLoadingType:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.loadingType=t},handleScroll:function(){this.updateView(),this.loading||this.completed||this.margin.bottom>=0&&(this.$emit(this.INFINITE_SCROLL),this.setLoadingType(this.INFINITE_SCROLL))},handleTouchStart:function(t){this.loading||!this.hasListen(this.PULL_UP)&&!this.hasListen(this.PULL_DOWN)||this.margin.top<0&&this.margin.bottom<0||(this.pull.from=t.touches.item(0).pageY)},handleTouchMove:function(t){if(!(this.loading||this.pull.from<0)){this.pull.to=t.touches.item(0).pageY;var e=this.pull.to-this.pull.from;e>0&&this.margin.top>0&&this.hasListen(this.PULL_DOWN)?this.pull.type=this.PULL_DOWN:e<0&&this.margin.bottom>0&&this.hasListen(this.PULL_UP)?this.pull.type=this.PULL_UP:this.pull.type=null,this.pull.distance=Math.abs(e),this.pull.available=this.pull.distance>=this.distance}},handleTouchEnd:function(){this.pull.distance>=this.distance?this.PULL_UP!==this.pull.type&&this.PULL_DOWN!==this.pull.type||(this.$emit(this.pull.type),this.setLoadingType(this.pull.type)):this.resetPull()},resetPull:function(){this.pull={from:-1,to:-1,distance:0,type:null,available:!1}},bindEvents:function(){var t=this;this.hasListen(this.INFINITE_SCROLL)&&["scroll","resize"].forEach(function(e){t._container.addEventListener(e,t.handleScroll)}),(this.hasListen(this.PULL_UP)||this.hasListen(this.PULL_DOWN))&&(this._container.addEventListener("touchstart",this.handleTouchStart),this._container.addEventListener("touchmove",this.handleTouchMove),this._container.addEventListener("touchend",this.handleTouchEnd))},hasListen:function(t){return this.listens.indexOf(t)>=0},init:function(){this.bindEvents(),this.updateView(),this.initScroll&&this.handleScroll()}},mounted:function(){var t=this;this.$nextTick(function(){t.init()})}}},function(t,e,n){"use strict";var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"vue-data-loading"},[t.PULL_DOWN===t.pull.type&&t.pulldown?n("div",{staticClass:"loading-header",style:{height:t.pullHeight+"px"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:!t.pull.available,expression:"!pull.available"}],staticClass:"header-text"},[t._t(t.PULL_DOWN+"-before",[t._v("下拉刷新数据")])],2),t._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:t.pull.available&&t.PULL_DOWN!==t.loadingType,expression:"pull.available && PULL_DOWN !== loadingType"}],staticClass:"header-text"},[t._t(t.PULL_DOWN+"-ready",[t._v("松开刷新数据")])],2),t._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:t.PULL_DOWN===t.loadingType,expression:"PULL_DOWN === loadingType"}],staticClass:"header-text"},[t._t(t.PULL_DOWN+"-loading",[t._v("刷新中...")])],2)]):t._e(),t._v(" "),n("div",{staticClass:"loading-content"},[t._t("default")],2),t._v(" "),t.showFooter?[t.PULL_UP!==t.pull.type||t.completed?t._e():n("div",{staticClass:"loading-footer",style:{height:t.pullHeight+"px"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:!t.pull.available,expression:"!pull.available"}],staticClass:"footer-text"},[t._t(t.PULL_UP+"-before",[t._v("上拉加载数据")])],2),t._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:t.pull.available&&t.PULL_UP!==t.loadingType,expression:"pull.available && PULL_UP !== loadingType"}],staticClass:"footer-text"},[t._t(t.PULL_UP+"-ready",[t._v("松开加载数据")])],2),t._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:t.PULL_UP===t.loadingType,expression:"PULL_UP === loadingType"}],staticClass:"footer-text"},[t._t(t.PULL_UP+"-loading",[t._v("加载中...")])],2)]),t._v(" "),t.loading&&t.INFINITE_SCROLL===t.loadingType&&!t.completed?n("div",{staticClass:"loading-footer",style:{height:t.distance+"px"}},[n("div",{staticClass:"footer-text"},[t._t(t.INFINITE_SCROLL+"-loading",[t._v("加载中...")])],2)]):t._e(),t._v(" "),!t.loading&&t.completed?n("div",{staticClass:"loading-footer",style:{height:t.distance+"px"}},[n("div",{staticClass:"footer-text"},[t._t("completed",[t._v("已加载全部内容")])],2)]):t._e()]:t._e()],2)},o=[],a={render:i,staticRenderFns:o};e.a=a}])});