From 239e3b0bb49480038e515a83402753042047d6d7 Mon Sep 17 00:00:00 2001 From: Peach Date: Thu, 16 Aug 2018 14:24:54 +0800 Subject: [PATCH 001/152] Optimize throttle logic to ensure training call --- src/components/InfiniteLoading.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/InfiniteLoading.vue b/src/components/InfiniteLoading.vue index de0248f..00fcb3d 100644 --- a/src/components/InfiniteLoading.vue +++ b/src/components/InfiniteLoading.vue @@ -134,8 +134,10 @@ if (ev && ev.constructor === Event) { if (!this.inThrottle) { this.inThrottle = true; - this.attemptLoad(); - setTimeout(() => { this.inThrottle = false; }, this.throttleLimit); + setTimeout(() => { + this.attemptLoad(); + this.inThrottle = false; + }, this.throttleLimit); } } else { this.attemptLoad(); From fe272f5f916840fd7ca5182b6b4b84130fd95195 Mon Sep 17 00:00:00 2001 From: Peach Date: Thu, 16 Aug 2018 14:30:14 +0800 Subject: [PATCH 002/152] Modify unit test for throttle feature --- test/unit/specs/InfiniteLoading.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/specs/InfiniteLoading.spec.js b/test/unit/specs/InfiniteLoading.spec.js index 68c0312..d7bdd46 100644 --- a/test/unit/specs/InfiniteLoading.spec.js +++ b/test/unit/specs/InfiniteLoading.spec.js @@ -420,7 +420,7 @@ describe('vue-infinite-loading', () => { continuesCall(() => { scrollParent.scrollTop += 10; }, 10, () => { - expect(spyFn).to.have.been.callCount(1 + alreadyCalledTimes); + expect(spyFn).to.have.been.callCount(0 + alreadyCalledTimes); setTimeout(() => { expect(spyFn).to.have.been.callCount(1 + alreadyCalledTimes); done(); From 90e5f3a206faad347ab632b0aa746c83f765d837 Mon Sep 17 00:00:00 2001 From: Peach Date: Thu, 16 Aug 2018 14:30:56 +0800 Subject: [PATCH 003/152] Build for 2.3.3 --- dist/vue-infinite-loading.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/vue-infinite-loading.js b/dist/vue-infinite-loading.js index 6f37d58..743b1a8 100644 --- a/dist/vue-infinite-loading.js +++ b/dist/vue-infinite-loading.js @@ -1,6 +1,6 @@ /*! - * vue-infinite-loading v2.3.2 + * vue-infinite-loading v2.3.3 * (c) 2016-2018 PeachScript * MIT License */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VueInfiniteLoading=t():e.VueInfiniteLoading=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(i[n])return i[n].exports;var a=i[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var i={};return t.m=e,t.c=i,t.d=function(e,i,n){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=3)}([function(e,t){function i(e,t){var i=e[1]||"",a=e[3];if(!a)return i;if(t&&"function"==typeof btoa){var r=n(a);return[i].concat(a.sources.map(function(e){return"/*# sourceURL="+a.sourceRoot+e+" */"})).concat([r]).join("\n")}return[i].join("\n")}function n(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=i(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},t.i=function(e,i){"string"==typeof e&&(e=[[null,e,""]]);for(var n={},a=0;ai.parts.length&&(n.parts.length=i.parts.length)}else{for(var o=[],a=0;a',"\nscript:\n...\ninfiniteHandler($state) {\n ajax('https://www.example.com/api/news')\n .then((res) => {\n if (res.data.length) {\n $state.loaded();\n } else {\n $state.complete();\n }\n });\n}\n...","","more details: https://github.com/PeachScript/vue-infinite-loading/issues/57#issuecomment-324370549"].join("\n"),INFINITE_EVENT:"[Vue-infinite-loading warn]: `:on-infinite` property will be deprecated soon, please use `@infinite` event instead."},r={INFINITE_LOOP:["[Vue-infinite-loading error]: executed the callback function more than 10 times for a short time, it looks like searched a wrong scroll wrapper that doest not has fixed height or maximum height, please check it. If you want to force to set a element as scroll wrapper ranther than automatic searching, you can do this:",'\n\x3c!-- add a special attribute for the real scroll wrapper --\x3e\n
\n ...\n \x3c!-- set force-use-infinite-wrapper to true --\x3e\n \n
\n ',"more details: https://github.com/PeachScript/vue-infinite-loading/issues/55#issuecomment-316934169"].join("\n")},o=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e={passive:!0}}});window.addEventListener("testpassive",t,t),window.remove("testpassive",t,t)}catch(e){}return e}();t.a={name:"InfiniteLoading",data:function(){return{scrollParent:null,scrollHandler:null,isLoading:!1,isComplete:!1,isFirstLoad:!0,inThrottle:!1,throttleLimit:50,infiniteLoopChecked:!1,infiniteLoopTimer:null,continuousCallTimes:0}},components:{Spinner:n.a},computed:{isNoResults:{cache:!1,get:function(){var e=this.$slots["no-results"],t=e&&e[0].elm&&""===e[0].elm.textContent;return!this.isLoading&&this.isComplete&&this.isFirstLoad&&!t}},isNoMore:{cache:!1,get:function(){var e=this.$slots["no-more"],t=e&&e[0].elm&&""===e[0].elm.textContent;return!this.isLoading&&this.isComplete&&!this.isFirstLoad&&!t}}},props:{distance:{type:Number,default:100},onInfinite:Function,spinner:String,direction:{type:String,default:"bottom"},forceUseInfiniteWrapper:null},mounted:function(){var e=this;this.scrollParent=this.getScrollParent(),this.scrollHandler=function(e){var t=this;this.isLoading||(e&&e.constructor===Event?this.inThrottle||(this.inThrottle=!0,this.attemptLoad(),setTimeout(function(){t.inThrottle=!1},this.throttleLimit)):this.attemptLoad())}.bind(this),setTimeout(this.scrollHandler,1),this.scrollParent.addEventListener("scroll",this.scrollHandler,o),this.$on("$InfiniteLoading:loaded",function(t){e.isFirstLoad=!1,e.isLoading&&e.$nextTick(e.attemptLoad.bind(null,!0)),t&&t.target===e||console.warn(a.STATE_CHANGER)}),this.$on("$InfiniteLoading:complete",function(t){e.isLoading=!1,e.isComplete=!0,e.$nextTick(function(){e.$forceUpdate()}),e.scrollParent.removeEventListener("scroll",e.scrollHandler,o),t&&t.target===e||console.warn(a.STATE_CHANGER)}),this.$on("$InfiniteLoading:reset",function(){e.isLoading=!1,e.isComplete=!1,e.isFirstLoad=!0,e.inThrottle=!1,e.scrollParent.addEventListener("scroll",e.scrollHandler,o),setTimeout(e.scrollHandler,1)}),this.onInfinite&&console.warn(a.INFINITE_EVENT),this.stateChanger={loaded:function(){e.$emit("$InfiniteLoading:loaded",{target:e})},complete:function(){e.$emit("$InfiniteLoading:complete",{target:e})},reset:function(){e.$emit("$InfiniteLoading:reset",{target:e})}},this.$watch("forceUseInfiniteWrapper",function(){e.scrollParent=e.getScrollParent()})},deactivated:function(){this.isLoading=!1,this.scrollParent.removeEventListener("scroll",this.scrollHandler,o)},activated:function(){this.scrollParent.addEventListener("scroll",this.scrollHandler,o)},methods:{attemptLoad:function(e){var t=this,i=this.getCurrentDistance();!this.isComplete&&i<=this.distance&&this.$el.offsetWidth+this.$el.offsetHeight>0?(this.isLoading=!0,"function"==typeof this.onInfinite?this.onInfinite.call(null,this.stateChanger):this.$emit("infinite",this.stateChanger),!e||this.forceUseInfiniteWrapper||this.infiniteLoopChecked||(this.continuousCallTimes+=1,clearTimeout(this.infiniteLoopTimer),this.infiniteLoopTimer=setTimeout(function(){t.infiniteLoopChecked=!0},1e3),this.continuousCallTimes>10&&(console.error(r.INFINITE_LOOP),this.infiniteLoopChecked=!0))):this.isLoading=!1},getCurrentDistance:function(){var e=void 0;if("top"===this.direction)e=isNaN(this.scrollParent.scrollTop)?this.scrollParent.pageYOffset:this.scrollParent.scrollTop;else{e=this.$el.getBoundingClientRect().top-(this.scrollParent===window?window.innerHeight:this.scrollParent.getBoundingClientRect().bottom)}return e},getScrollParent:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.$el,t=void 0;return"BODY"===e.tagName?t=window:!this.forceUseInfiniteWrapper&&["scroll","auto"].indexOf(getComputedStyle(e).overflowY)>-1?t=e:(e.hasAttribute("infinite-wrapper")||e.hasAttribute("data-infinite-wrapper"))&&(t=e),t||this.getScrollParent(e.parentNode)}},destroyed:function(){this.isComplete||this.scrollParent.removeEventListener("scroll",this.scrollHandler,o)}}},function(e,t,i){"use strict";function n(e){i(10)}var a=i(12),r=i(13),o=i(2),s=n,l=o(a.a,r.a,!1,s,"data-v-6e1fd88f",null);t.a=l.exports},function(e,t,i){var n=i(11);"string"==typeof n&&(n=[[e.i,n,""]]),n.locals&&(e.exports=n.locals);i(1)("29881045",n,!0)},function(e,t,i){t=e.exports=i(0)(void 0),t.push([e.i,'.loading-wave-dots[data-v-6e1fd88f]{position:relative}.loading-wave-dots[data-v-6e1fd88f] .wave-item{position:absolute;top:50%;left:50%;display:inline-block;margin-top:-4px;width:8px;height:8px;border-radius:50%;-webkit-animation:loading-wave-dots-data-v-6e1fd88f linear 2.8s infinite;animation:loading-wave-dots-data-v-6e1fd88f linear 2.8s infinite}.loading-wave-dots[data-v-6e1fd88f] .wave-item:first-child{margin-left:-36px}.loading-wave-dots[data-v-6e1fd88f] .wave-item:nth-child(2){margin-left:-20px;-webkit-animation-delay:.14s;animation-delay:.14s}.loading-wave-dots[data-v-6e1fd88f] .wave-item:nth-child(3){margin-left:-4px;-webkit-animation-delay:.28s;animation-delay:.28s}.loading-wave-dots[data-v-6e1fd88f] .wave-item:nth-child(4){margin-left:12px;-webkit-animation-delay:.42s;animation-delay:.42s}.loading-wave-dots[data-v-6e1fd88f] .wave-item:last-child{margin-left:28px;-webkit-animation-delay:.56s;animation-delay:.56s}@-webkit-keyframes loading-wave-dots-data-v-6e1fd88f{0%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}10%{-webkit-transform:translateY(-6px);transform:translateY(-6px);background:#999}20%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}to{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}}@keyframes loading-wave-dots-data-v-6e1fd88f{0%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}10%{-webkit-transform:translateY(-6px);transform:translateY(-6px);background:#999}20%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}to{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}}.loading-circles[data-v-6e1fd88f] .circle-item{width:5px;height:5px;-webkit-animation:loading-circles-data-v-6e1fd88f linear .75s infinite;animation:loading-circles-data-v-6e1fd88f linear .75s infinite}.loading-circles[data-v-6e1fd88f] .circle-item:first-child{margin-top:-14.5px;margin-left:-2.5px}.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(2){margin-top:-11.26px;margin-left:6.26px}.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(3){margin-top:-2.5px;margin-left:9.5px}.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(4){margin-top:6.26px;margin-left:6.26px}.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(5){margin-top:9.5px;margin-left:-2.5px}.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(6){margin-top:6.26px;margin-left:-11.26px}.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(7){margin-top:-2.5px;margin-left:-14.5px}.loading-circles[data-v-6e1fd88f] .circle-item:last-child{margin-top:-11.26px;margin-left:-11.26px}@-webkit-keyframes loading-circles-data-v-6e1fd88f{0%{background:#dfdfdf}90%{background:#505050}to{background:#dfdfdf}}@keyframes loading-circles-data-v-6e1fd88f{0%{background:#dfdfdf}90%{background:#505050}to{background:#dfdfdf}}.loading-bubbles[data-v-6e1fd88f] .bubble-item{background:#666;-webkit-animation:loading-bubbles-data-v-6e1fd88f linear .75s infinite;animation:loading-bubbles-data-v-6e1fd88f linear .75s infinite}.loading-bubbles[data-v-6e1fd88f] .bubble-item:first-child{margin-top:-12.5px;margin-left:-.5px}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(2){margin-top:-9.26px;margin-left:8.26px}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(3){margin-top:-.5px;margin-left:11.5px}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(4){margin-top:8.26px;margin-left:8.26px}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(5){margin-top:11.5px;margin-left:-.5px}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(6){margin-top:8.26px;margin-left:-9.26px}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(7){margin-top:-.5px;margin-left:-12.5px}.loading-bubbles[data-v-6e1fd88f] .bubble-item:last-child{margin-top:-9.26px;margin-left:-9.26px}@-webkit-keyframes loading-bubbles-data-v-6e1fd88f{0%{width:1px;height:1px;box-shadow:0 0 0 3px #666}90%{width:1px;height:1px;box-shadow:0 0 0 0 #666}to{width:1px;height:1px;box-shadow:0 0 0 3px #666}}@keyframes loading-bubbles-data-v-6e1fd88f{0%{width:1px;height:1px;box-shadow:0 0 0 3px #666}90%{width:1px;height:1px;box-shadow:0 0 0 0 #666}to{width:1px;height:1px;box-shadow:0 0 0 3px #666}}.loading-default[data-v-6e1fd88f]{position:relative;border:1px solid #999;-webkit-animation:loading-rotating-data-v-6e1fd88f ease 1.5s infinite;animation:loading-rotating-data-v-6e1fd88f ease 1.5s infinite}.loading-default[data-v-6e1fd88f]:before{content:"";position:absolute;display:block;top:0;left:50%;margin-top:-3px;margin-left:-3px;width:6px;height:6px;background-color:#999;border-radius:50%}.loading-spiral[data-v-6e1fd88f]{border:2px solid #777;border-right-color:transparent;-webkit-animation:loading-rotating-data-v-6e1fd88f linear .85s infinite;animation:loading-rotating-data-v-6e1fd88f linear .85s infinite}@-webkit-keyframes loading-rotating-data-v-6e1fd88f{0%{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes loading-rotating-data-v-6e1fd88f{0%{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}.loading-bubbles[data-v-6e1fd88f],.loading-circles[data-v-6e1fd88f]{position:relative}.loading-bubbles[data-v-6e1fd88f] .bubble-item,.loading-circles[data-v-6e1fd88f] .circle-item{position:absolute;top:50%;left:50%;display:inline-block;border-radius:50%}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(2),.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(2){-webkit-animation-delay:93ms;animation-delay:93ms}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(3),.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(3){-webkit-animation-delay:.186s;animation-delay:.186s}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(4),.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(4){-webkit-animation-delay:.279s;animation-delay:.279s}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(5),.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(5){-webkit-animation-delay:.372s;animation-delay:.372s}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(6),.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(6){-webkit-animation-delay:.465s;animation-delay:.465s}.loading-bubbles[data-v-6e1fd88f] .bubble-item:nth-child(7),.loading-circles[data-v-6e1fd88f] .circle-item:nth-child(7){-webkit-animation-delay:.558s;animation-delay:.558s}.loading-bubbles[data-v-6e1fd88f] .bubble-item:last-child,.loading-circles[data-v-6e1fd88f] .circle-item:last-child{-webkit-animation-delay:.651s;animation-delay:.651s}',""])},function(e,t,i){"use strict";var n={BUBBLES:{render:function(e){return e("span",{attrs:{class:"loading-bubbles"}},Array.apply(Array,Array(8)).map(function(){return e("span",{attrs:{class:"bubble-item"}})}))}},CIRCLES:{render:function(e){return e("span",{attrs:{class:"loading-circles"}},Array.apply(Array,Array(8)).map(function(){return e("span",{attrs:{class:"circle-item"}})}))}},DEFAULT:{render:function(e){return e("i",{attrs:{class:"loading-default"}})}},SPIRAL:{render:function(e){return e("i",{attrs:{class:"loading-spiral"}})}},WAVEDOTS:{render:function(e){return e("span",{attrs:{class:"loading-wave-dots"}},Array.apply(Array,Array(5)).map(function(){return e("span",{attrs:{class:"wave-item"}})}))}}};t.a={name:"spinner",computed:{spinnerView:function(){return n[(this.spinner||"").toUpperCase()]||n.DEFAULT}},props:{spinner:String}}},function(e,t,i){"use strict";var n=function(){var e=this,t=e.$createElement;return(e._self._c||t)(e.spinnerView,{tag:"component"})},a=[],r={render:n,staticRenderFns:a};t.a=r},function(e,t,i){"use strict";var n=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"infinite-loading-container"},[i("div",{directives:[{name:"show",rawName:"v-show",value:e.isLoading,expression:"isLoading"}]},[e._t("spinner",[i("spinner",{attrs:{spinner:e.spinner}})])],2),e._v(" "),i("div",{directives:[{name:"show",rawName:"v-show",value:e.isNoResults,expression:"isNoResults"}],staticClass:"infinite-status-prompt"},[e._t("no-results",[e._v("No results :(")])],2),e._v(" "),i("div",{directives:[{name:"show",rawName:"v-show",value:e.isNoMore,expression:"isNoMore"}],staticClass:"infinite-status-prompt"},[e._t("no-more",[e._v("No more data :)")])],2)])},a=[],r={render:n,staticRenderFns:a};t.a=r}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.VueInfiniteLoading=e():t.VueInfiniteLoading=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var i={};return e.m=t,e.c=i,e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=3)}([function(t,e){function i(t,e){var i=t[1]||"",a=t[3];if(!a)return i;if(e&&"function"==typeof btoa){var r=n(a);return[i].concat(a.sources.map(function(t){return"/*# sourceURL="+a.sourceRoot+t+" */"})).concat([r]).join("\n")}return[i].join("\n")}function n(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 n=i(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n}).join("")},e.i=function(t,i){"string"==typeof t&&(t=[[null,t,""]]);for(var n={},a=0;ai.parts.length&&(n.parts.length=i.parts.length)}else{for(var o=[],a=0;a',"\nscript:\n...\ninfiniteHandler($state) {\n ajax('https://www.example.com/api/news')\n .then((res) => {\n if (res.data.length) {\n $state.loaded();\n } else {\n $state.complete();\n }\n });\n}\n...","","more details: https://github.com/PeachScript/vue-infinite-loading/issues/57#issuecomment-324370549"].join("\n"),INFINITE_EVENT:"[Vue-infinite-loading warn]: `:on-infinite` property will be deprecated soon, please use `@infinite` event instead."},r={INFINITE_LOOP:["[Vue-infinite-loading error]: executed the callback function more than 10 times for a short time, it looks like searched a wrong scroll wrapper that doest not has fixed height or maximum height, please check it. If you want to force to set a element as scroll wrapper ranther than automatic searching, you can do this:",'\n\x3c!-- add a special attribute for the real scroll wrapper --\x3e\n
\n ...\n \x3c!-- set force-use-infinite-wrapper to true --\x3e\n \n
\n ',"more details: https://github.com/PeachScript/vue-infinite-loading/issues/55#issuecomment-316934169"].join("\n")},o=function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t={passive:!0}}});window.addEventListener("testpassive",e,e),window.remove("testpassive",e,e)}catch(t){}return t}();e.a={name:"InfiniteLoading",data:function(){return{scrollParent:null,scrollHandler:null,isLoading:!1,isComplete:!1,isFirstLoad:!0,inThrottle:!1,throttleLimit:50,infiniteLoopChecked:!1,infiniteLoopTimer:null,continuousCallTimes:0}},components:{Spinner:n.a},computed:{isNoResults:{cache:!1,get:function(){var t=this.$slots["no-results"],e=t&&t[0].elm&&""===t[0].elm.textContent;return!this.isLoading&&this.isComplete&&this.isFirstLoad&&!e}},isNoMore:{cache:!1,get:function(){var t=this.$slots["no-more"],e=t&&t[0].elm&&""===t[0].elm.textContent;return!this.isLoading&&this.isComplete&&!this.isFirstLoad&&!e}}},props:{distance:{type:Number,default:100},onInfinite:Function,spinner:String,direction:{type:String,default:"bottom"},forceUseInfiniteWrapper:null},mounted:function(){var t=this;this.scrollParent=this.getScrollParent(),this.scrollHandler=function(t){var e=this;this.isLoading||(t&&t.constructor===Event?this.inThrottle||(this.inThrottle=!0,setTimeout(function(){e.attemptLoad(),e.inThrottle=!1},this.throttleLimit)):this.attemptLoad())}.bind(this),setTimeout(this.scrollHandler,1),this.scrollParent.addEventListener("scroll",this.scrollHandler,o),this.$on("$InfiniteLoading:loaded",function(e){t.isFirstLoad=!1,t.isLoading&&t.$nextTick(t.attemptLoad.bind(null,!0)),e&&e.target===t||console.warn(a.STATE_CHANGER)}),this.$on("$InfiniteLoading:complete",function(e){t.isLoading=!1,t.isComplete=!0,t.$nextTick(function(){t.$forceUpdate()}),t.scrollParent.removeEventListener("scroll",t.scrollHandler,o),e&&e.target===t||console.warn(a.STATE_CHANGER)}),this.$on("$InfiniteLoading:reset",function(){t.isLoading=!1,t.isComplete=!1,t.isFirstLoad=!0,t.inThrottle=!1,t.scrollParent.addEventListener("scroll",t.scrollHandler,o),setTimeout(t.scrollHandler,1)}),this.onInfinite&&console.warn(a.INFINITE_EVENT),this.stateChanger={loaded:function(){t.$emit("$InfiniteLoading:loaded",{target:t})},complete:function(){t.$emit("$InfiniteLoading:complete",{target:t})},reset:function(){t.$emit("$InfiniteLoading:reset",{target:t})}},this.$watch("forceUseInfiniteWrapper",function(){t.scrollParent=t.getScrollParent()})},deactivated:function(){this.isLoading=!1,this.scrollParent.removeEventListener("scroll",this.scrollHandler,o)},activated:function(){this.scrollParent.addEventListener("scroll",this.scrollHandler,o)},methods:{attemptLoad:function(t){var e=this,i=this.getCurrentDistance();!this.isComplete&&i<=this.distance&&this.$el.offsetWidth+this.$el.offsetHeight>0?(this.isLoading=!0,"function"==typeof this.onInfinite?this.onInfinite.call(null,this.stateChanger):this.$emit("infinite",this.stateChanger),!t||this.forceUseInfiniteWrapper||this.infiniteLoopChecked||(this.continuousCallTimes+=1,clearTimeout(this.infiniteLoopTimer),this.infiniteLoopTimer=setTimeout(function(){e.infiniteLoopChecked=!0},1e3),this.continuousCallTimes>10&&(console.error(r.INFINITE_LOOP),this.infiniteLoopChecked=!0))):this.isLoading=!1},getCurrentDistance:function(){var t=void 0;if("top"===this.direction)t=isNaN(this.scrollParent.scrollTop)?this.scrollParent.pageYOffset:this.scrollParent.scrollTop;else{t=this.$el.getBoundingClientRect().top-(this.scrollParent===window?window.innerHeight:this.scrollParent.getBoundingClientRect().bottom)}return t},getScrollParent:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.$el,e=void 0;return"BODY"===t.tagName?e=window:!this.forceUseInfiniteWrapper&&["scroll","auto"].indexOf(getComputedStyle(t).overflowY)>-1?e=t:(t.hasAttribute("infinite-wrapper")||t.hasAttribute("data-infinite-wrapper"))&&(e=t),e||this.getScrollParent(t.parentNode)}},destroyed:function(){this.isComplete||this.scrollParent.removeEventListener("scroll",this.scrollHandler,o)}}},function(t,e,i){"use strict";function n(t){i(10)}var a=i(12),r=i(13),o=i(2),s=n,l=o(a.a,r.a,s,"data-v-10a220cc",null);e.a=l.exports},function(t,e,i){var n=i(11);"string"==typeof n&&(n=[[t.i,n,""]]),n.locals&&(t.exports=n.locals);i(1)("2914e7ad",n,!0)},function(t,e,i){e=t.exports=i(0)(void 0),e.push([t.i,'.loading-wave-dots[data-v-10a220cc]{position:relative}.loading-wave-dots[data-v-10a220cc] .wave-item{position:absolute;top:50%;left:50%;display:inline-block;margin-top:-4px;width:8px;height:8px;border-radius:50%;-webkit-animation:loading-wave-dots-data-v-10a220cc linear 2.8s infinite;animation:loading-wave-dots-data-v-10a220cc linear 2.8s infinite}.loading-wave-dots[data-v-10a220cc] .wave-item:first-child{margin-left:-36px}.loading-wave-dots[data-v-10a220cc] .wave-item:nth-child(2){margin-left:-20px;-webkit-animation-delay:.14s;animation-delay:.14s}.loading-wave-dots[data-v-10a220cc] .wave-item:nth-child(3){margin-left:-4px;-webkit-animation-delay:.28s;animation-delay:.28s}.loading-wave-dots[data-v-10a220cc] .wave-item:nth-child(4){margin-left:12px;-webkit-animation-delay:.42s;animation-delay:.42s}.loading-wave-dots[data-v-10a220cc] .wave-item:last-child{margin-left:28px;-webkit-animation-delay:.56s;animation-delay:.56s}@-webkit-keyframes loading-wave-dots-data-v-10a220cc{0%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}10%{-webkit-transform:translateY(-6px);transform:translateY(-6px);background:#999}20%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}to{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}}@keyframes loading-wave-dots-data-v-10a220cc{0%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}10%{-webkit-transform:translateY(-6px);transform:translateY(-6px);background:#999}20%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}to{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}}.loading-circles[data-v-10a220cc] .circle-item{width:5px;height:5px;-webkit-animation:loading-circles-data-v-10a220cc linear .75s infinite;animation:loading-circles-data-v-10a220cc linear .75s infinite}.loading-circles[data-v-10a220cc] .circle-item:first-child{margin-top:-14.5px;margin-left:-2.5px}.loading-circles[data-v-10a220cc] .circle-item:nth-child(2){margin-top:-11.26px;margin-left:6.26px}.loading-circles[data-v-10a220cc] .circle-item:nth-child(3){margin-top:-2.5px;margin-left:9.5px}.loading-circles[data-v-10a220cc] .circle-item:nth-child(4){margin-top:6.26px;margin-left:6.26px}.loading-circles[data-v-10a220cc] .circle-item:nth-child(5){margin-top:9.5px;margin-left:-2.5px}.loading-circles[data-v-10a220cc] .circle-item:nth-child(6){margin-top:6.26px;margin-left:-11.26px}.loading-circles[data-v-10a220cc] .circle-item:nth-child(7){margin-top:-2.5px;margin-left:-14.5px}.loading-circles[data-v-10a220cc] .circle-item:last-child{margin-top:-11.26px;margin-left:-11.26px}@-webkit-keyframes loading-circles-data-v-10a220cc{0%{background:#dfdfdf}90%{background:#505050}to{background:#dfdfdf}}@keyframes loading-circles-data-v-10a220cc{0%{background:#dfdfdf}90%{background:#505050}to{background:#dfdfdf}}.loading-bubbles[data-v-10a220cc] .bubble-item{background:#666;-webkit-animation:loading-bubbles-data-v-10a220cc linear .75s infinite;animation:loading-bubbles-data-v-10a220cc linear .75s infinite}.loading-bubbles[data-v-10a220cc] .bubble-item:first-child{margin-top:-12.5px;margin-left:-.5px}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(2){margin-top:-9.26px;margin-left:8.26px}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(3){margin-top:-.5px;margin-left:11.5px}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(4){margin-top:8.26px;margin-left:8.26px}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(5){margin-top:11.5px;margin-left:-.5px}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(6){margin-top:8.26px;margin-left:-9.26px}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(7){margin-top:-.5px;margin-left:-12.5px}.loading-bubbles[data-v-10a220cc] .bubble-item:last-child{margin-top:-9.26px;margin-left:-9.26px}@-webkit-keyframes loading-bubbles-data-v-10a220cc{0%{width:1px;height:1px;box-shadow:0 0 0 3px #666}90%{width:1px;height:1px;box-shadow:0 0 0 0 #666}to{width:1px;height:1px;box-shadow:0 0 0 3px #666}}@keyframes loading-bubbles-data-v-10a220cc{0%{width:1px;height:1px;box-shadow:0 0 0 3px #666}90%{width:1px;height:1px;box-shadow:0 0 0 0 #666}to{width:1px;height:1px;box-shadow:0 0 0 3px #666}}.loading-default[data-v-10a220cc]{position:relative;border:1px solid #999;-webkit-animation:loading-rotating-data-v-10a220cc ease 1.5s infinite;animation:loading-rotating-data-v-10a220cc ease 1.5s infinite}.loading-default[data-v-10a220cc]:before{content:"";position:absolute;display:block;top:0;left:50%;margin-top:-3px;margin-left:-3px;width:6px;height:6px;background-color:#999;border-radius:50%}.loading-spiral[data-v-10a220cc]{border:2px solid #777;border-right-color:transparent;-webkit-animation:loading-rotating-data-v-10a220cc linear .85s infinite;animation:loading-rotating-data-v-10a220cc linear .85s infinite}@-webkit-keyframes loading-rotating-data-v-10a220cc{0%{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes loading-rotating-data-v-10a220cc{0%{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}.loading-bubbles[data-v-10a220cc],.loading-circles[data-v-10a220cc]{position:relative}.loading-bubbles[data-v-10a220cc] .bubble-item,.loading-circles[data-v-10a220cc] .circle-item{position:absolute;top:50%;left:50%;display:inline-block;border-radius:50%}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(2),.loading-circles[data-v-10a220cc] .circle-item:nth-child(2){-webkit-animation-delay:93ms;animation-delay:93ms}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(3),.loading-circles[data-v-10a220cc] .circle-item:nth-child(3){-webkit-animation-delay:.186s;animation-delay:.186s}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(4),.loading-circles[data-v-10a220cc] .circle-item:nth-child(4){-webkit-animation-delay:.279s;animation-delay:.279s}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(5),.loading-circles[data-v-10a220cc] .circle-item:nth-child(5){-webkit-animation-delay:.372s;animation-delay:.372s}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(6),.loading-circles[data-v-10a220cc] .circle-item:nth-child(6){-webkit-animation-delay:.465s;animation-delay:.465s}.loading-bubbles[data-v-10a220cc] .bubble-item:nth-child(7),.loading-circles[data-v-10a220cc] .circle-item:nth-child(7){-webkit-animation-delay:.558s;animation-delay:.558s}.loading-bubbles[data-v-10a220cc] .bubble-item:last-child,.loading-circles[data-v-10a220cc] .circle-item:last-child{-webkit-animation-delay:.651s;animation-delay:.651s}',""])},function(t,e,i){"use strict";var n={BUBBLES:{render:function(t){return t("span",{attrs:{class:"loading-bubbles"}},Array.apply(Array,Array(8)).map(function(){return t("span",{attrs:{class:"bubble-item"}})}))}},CIRCLES:{render:function(t){return t("span",{attrs:{class:"loading-circles"}},Array.apply(Array,Array(8)).map(function(){return t("span",{attrs:{class:"circle-item"}})}))}},DEFAULT:{render:function(t){return t("i",{attrs:{class:"loading-default"}})}},SPIRAL:{render:function(t){return t("i",{attrs:{class:"loading-spiral"}})}},WAVEDOTS:{render:function(t){return t("span",{attrs:{class:"loading-wave-dots"}},Array.apply(Array,Array(5)).map(function(){return t("span",{attrs:{class:"wave-item"}})}))}}};e.a={name:"spinner",computed:{spinnerView:function(){return n[(this.spinner||"").toUpperCase()]||n.DEFAULT}},props:{spinner:String}}},function(t,e,i){"use strict";var n=function(){var t=this,e=t.$createElement;return(t._self._c||e)(t.spinnerView,{tag:"component"})},a=[],r={render:n,staticRenderFns:a};e.a=r},function(t,e,i){"use strict";var n=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"infinite-loading-container"},[i("div",{directives:[{name:"show",rawName:"v-show",value:t.isLoading,expression:"isLoading"}]},[t._t("spinner",[i("spinner",{attrs:{spinner:t.spinner}})])],2),t._v(" "),i("div",{directives:[{name:"show",rawName:"v-show",value:t.isNoResults,expression:"isNoResults"}],staticClass:"infinite-status-prompt"},[t._t("no-results",[t._v("No results :(")])],2),t._v(" "),i("div",{directives:[{name:"show",rawName:"v-show",value:t.isNoMore,expression:"isNoMore"}],staticClass:"infinite-status-prompt"},[t._t("no-more",[t._v("No more data :)")])],2)])},a=[],r={render:n,staticRenderFns:a};e.a=r}])}); \ No newline at end of file From c759f44ee91270d768bd06ea97dcb5a666413865 Mon Sep 17 00:00:00 2001 From: Peach Date: Thu, 16 Aug 2018 14:31:00 +0800 Subject: [PATCH 004/152] Upgrade to 2.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ee971c..a5441b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-infinite-loading", - "version": "2.3.2", + "version": "2.3.3", "description": "An infinite scroll plugin for Vue.js", "main": "dist/vue-infinite-loading.js", "typings": "types/index.d.ts", From 4bcaf669732d44ea2e9452b97dd272f83ec50455 Mon Sep 17 00:00:00 2001 From: Peach Date: Wed, 22 Aug 2018 18:08:27 +0800 Subject: [PATCH 005/152] chore: add commitlint to check commit msg --- package.json | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a5441b8..097439a 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,8 @@ "build": "NODE_ENV=production webpack -p --progress --hide-modules", "lint": "eslint --ext .js,.vue src", "test": "BABEL_ENV=test karma start", + "precommit": "npm run lint", + "commitmsg": "commitlint -E GIT_PARAMS", "release": "bash ./release.sh" }, "keywords": [ @@ -36,6 +38,8 @@ }, "homepage": "https://github.com/PeachScript/vue-infinite-loading", "devDependencies": { + "@commitlint/cli": "^7.0.0", + "@commitlint/config-conventional": "^7.0.1", "autoprefixer": "^7.1.2", "babel-core": "^6.25.0", "babel-eslint": "^7.2.3", @@ -54,6 +58,7 @@ "eslint-plugin-html": "^3.2.0", "eslint-plugin-import": "^2.7.0", "html-webpack-plugin": "^2.30.1", + "husky": "^0.14.3", "karma": "^1.7.0", "karma-chai": "^0.1.0", "karma-coverage": "^1.1.1", @@ -66,7 +71,6 @@ "less-loader": "^4.0.5", "mocha": "^3.5.0", "phantomjs-prebuilt": "^2.1.15", - "pre-commit": "^1.2.2", "sinon": "^2.4.1", "sinon-chai": "^2.13.0", "style-loader": "^0.18.2", @@ -81,13 +85,27 @@ "vue": "^2.2.0" }, "license": "MIT", - "pre-commit": [ - "lint" - ], "browserslist": [ "> 1%", "last 1 versions", "last 4 Android versions", "last 3 iOS versions" - ] + ], + "commitlint": { + "extends": [ + "@commitlint/config-conventional" + ], + "rules": { + "scope-enum": [ + 2, + "always", + [ + "core", + "config", + "spinner", + "deps" + ] + ] + } + } } From ae9dd2ba73379be96eb1f7acb382e206021ea22c Mon Sep 17 00:00:00 2001 From: Simon Tarchichi Date: Wed, 29 Aug 2018 17:03:31 +0200 Subject: [PATCH 006/152] refactor: improve export in TS definition #177 --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index fc6cdf5..729148e 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -47,4 +47,4 @@ declare class InfiniteLoading extends Vue { $slots: InfiniteLoading.Slots; } -export = InfiniteLoading; +export default InfiniteLoading; From 95f7e59a0dc82ea3a48d2e6b460cd555d2f894ac Mon Sep 17 00:00:00 2001 From: Peach Date: Thu, 6 Sep 2018 11:43:29 +0800 Subject: [PATCH 007/152] style: use eslint-plugin-vue to lint code and optimize eslint config --- .eslintignore | 3 - .eslintrc.yml | 24 - package.json | 23 +- src/components/InfiniteLoading.vue | 574 ++++++++++++------------ src/components/Spinner.vue | 133 +++--- src/index.js | 2 +- test/unit/specs/InfiniteLoading.spec.js | 6 +- webpack.config.js | 2 +- 8 files changed, 373 insertions(+), 394 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.yml diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 853251d..0000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -/karma.conf.js -/webpack.config.js -/dist/*.js diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 601f218..0000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - root: true - extends: airbnb-base - parser: babel-eslint - parserOptions: - ecmaVersion: 6 - sourceType: module - ecmaFeatures: - impliedStrict: true - env: - browser: true - plugins: - - html - settings: - import/resolver: - webpack: - config: ./webpack.config.js - rules: - import/extensions: - - error - - always - - - js: never - vue: never diff --git a/package.json b/package.json index 097439a..e788521 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "scripts": { "dev": "webpack-dev-server --hot --info=false --port 8000", "build": "NODE_ENV=production webpack -p --progress --hide-modules", - "lint": "eslint --ext .js,.vue src", + "lint": "eslint -f friendly \"{src,test/unit/specs}/**/*.{js,vue}\"", "test": "BABEL_ENV=test karma start", "precommit": "npm run lint", "commitmsg": "commitlint -E GIT_PARAMS", @@ -42,7 +42,6 @@ "@commitlint/config-conventional": "^7.0.1", "autoprefixer": "^7.1.2", "babel-core": "^6.25.0", - "babel-eslint": "^7.2.3", "babel-loader": "^7.1.1", "babel-plugin-istanbul": "^4.1.4", "babel-plugin-transform-runtime": "^6.23.0", @@ -50,13 +49,12 @@ "babel-preset-stage-2": "^6.24.1", "chai": "^3.5.0", "css-loader": "^0.28.4", - "eslint": "^4.4.1", - "eslint-config-airbnb-base": "^11.3.1", - "eslint-friendly-formatter": "^3.0.0", - "eslint-import-resolver-webpack": "^0.8.3", - "eslint-loader": "^1.9.0", - "eslint-plugin-html": "^3.2.0", - "eslint-plugin-import": "^2.7.0", + "eslint": "^4.19.1", + "eslint-config-airbnb-base": "^13.1.0", + "eslint-formatter-friendly": "^6.0.0", + "eslint-loader": "^2.1.0", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-vue": "^4.7.1", "html-webpack-plugin": "^2.30.1", "husky": "^0.14.3", "karma": "^1.7.0", @@ -107,5 +105,12 @@ ] ] } + }, + "eslintConfig": { + "root": true, + "extends": [ + "airbnb-base", + "plugin:vue/essential" + ] } } diff --git a/src/components/InfiniteLoading.vue b/src/components/InfiniteLoading.vue index 00fcb3d..aeaa330 100644 --- a/src/components/InfiniteLoading.vue +++ b/src/components/InfiniteLoading.vue @@ -14,323 +14,327 @@ diff --git a/src/components/Spinner.vue b/src/components/Spinner.vue index 0680ee7..77186a4 100644 --- a/src/components/Spinner.vue +++ b/src/components/Spinner.vue @@ -2,80 +2,77 @@ diff --git a/src/index.js b/src/index.js index a9dc121..1adc434 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -import InfiniteLoading from './components/InfiniteLoading'; +import InfiniteLoading from './components/InfiniteLoading.vue'; export default InfiniteLoading; diff --git a/test/unit/specs/InfiniteLoading.spec.js b/test/unit/specs/InfiniteLoading.spec.js index d7bdd46..869bf01 100644 --- a/test/unit/specs/InfiniteLoading.spec.js +++ b/test/unit/specs/InfiniteLoading.spec.js @@ -1,7 +1,7 @@ /* eslint-disable no-console */ import Vue from 'vue/dist/vue.common'; -import InfiniteLoading from '../../../src/components/InfiniteLoading'; +import InfiniteLoading from '../../../src/components/InfiniteLoading.vue'; Vue.config.productionTip = false; @@ -159,7 +159,7 @@ describe('vue-infinite-loading', () => { }, methods: { infiniteHandler: function infiniteHandler() { - const scrollParent = this.$refs.infiniteLoading.scrollParent; + const { scrollParent } = this.$refs.infiniteLoading; const loadCountEachTime = 10; this.list.push(...new Array(loadCountEachTime + 1).join('1').split('')); @@ -413,7 +413,7 @@ describe('vue-infinite-loading', () => { spinner: 'waveDots', }, mounted: function mounted() { - const scrollParent = this.$refs.infiniteLoading.scrollParent; + const { scrollParent } = this.$refs.infiniteLoading; const spyFn = sinon.spy(this.$refs.infiniteLoading, 'attemptLoad'); const alreadyCalledTimes = 1; // it will be called immediately after mount diff --git a/webpack.config.js b/webpack.config.js index 3327a36..90343b1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -27,7 +27,7 @@ module.exports = { include: [path.join(__dirname, './src'), path.join(__dirname, './test')], loader: 'eslint-loader', options: { - formatter: require('eslint-friendly-formatter') + formatter: require('eslint-formatter-friendly') } }, { From ccff4ce793ad599da178bb94c27e74a3be91b74c Mon Sep 17 00:00:00 2001 From: Peach Date: Fri, 7 Sep 2018 10:43:58 +0800 Subject: [PATCH 008/152] refactor: fix number determine logic --- src/components/InfiniteLoading.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/InfiniteLoading.vue b/src/components/InfiniteLoading.vue index aeaa330..f5f3496 100644 --- a/src/components/InfiniteLoading.vue +++ b/src/components/InfiniteLoading.vue @@ -273,9 +273,9 @@ export default { let distance; if (this.direction === 'top') { - distance = Number.isNaN(this.scrollParent.scrollTop) - ? this.scrollParent.pageYOffset - : this.scrollParent.scrollTop; + distance = typeof this.scrollParent.scrollTop === 'number' + ? this.scrollParent.scrollTop + : this.scrollParent.pageYOffset; } else { const infiniteElmOffsetTopFromBottom = this.$el.getBoundingClientRect().top; const scrollElmOffsetTopFromBottom = this.scrollParent === window From 0892185867374a9d826310c2d7168f88cdaf2dbd Mon Sep 17 00:00:00 2001 From: Peach Date: Fri, 7 Sep 2018 10:45:20 +0800 Subject: [PATCH 009/152] chore: fix vulnerabilities of dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e788521..c35ecf2 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "eslint-plugin-vue": "^4.7.1", "html-webpack-plugin": "^2.30.1", "husky": "^0.14.3", - "karma": "^1.7.0", + "karma": "^3.0.0", "karma-chai": "^0.1.0", "karma-coverage": "^1.1.1", "karma-mocha": "^1.3.0", @@ -65,9 +65,9 @@ "karma-sinon-chai": "^1.3.1", "karma-spec-reporter": "0.0.31", "karma-webpack": "^2.0.4", - "less": "^2.7.2", - "less-loader": "^4.0.5", - "mocha": "^3.5.0", + "less": "^3.8.1", + "less-loader": "^4.1.0", + "mocha": "^5.2.0", "phantomjs-prebuilt": "^2.1.15", "sinon": "^2.4.1", "sinon-chai": "^2.13.0", From 9ad0fcc2cc4277a43ac45dd246bc86b7344027ff Mon Sep 17 00:00:00 2001 From: Peach Date: Sat, 8 Sep 2018 21:39:38 +0800 Subject: [PATCH 010/152] chore: add eslint ignore configuration --- package.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c35ecf2..385f89a 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "scripts": { "dev": "webpack-dev-server --hot --info=false --port 8000", "build": "NODE_ENV=production webpack -p --progress --hide-modules", - "lint": "eslint -f friendly \"{src,test/unit/specs}/**/*.{js,vue}\"", + "lint": "eslint -f friendly --ext .js,.vue ./", "test": "BABEL_ENV=test karma start", "precommit": "npm run lint", "commitmsg": "commitlint -E GIT_PARAMS", @@ -112,5 +112,11 @@ "airbnb-base", "plugin:vue/essential" ] - } + }, + "eslintIgnore": [ + "dist", + "test/unit/coverage", + "karma.conf.js", + "webpack.config.js" + ] } From 35113775cb49e3ff9a293a0e100549cd6bfe309d Mon Sep 17 00:00:00 2001 From: Peach Date: Sat, 8 Sep 2018 22:12:34 +0800 Subject: [PATCH 011/152] build: upgrade webpack and vue-loader --- karma.conf.js | 2 +- package.json | 20 +++++++++--------- webpack.config.js | 54 +++++++++++++++++++++++++++++++---------------- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 35a09e1..2cd440d 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -24,7 +24,7 @@ module.exports = function(config) { }, webpack: webpackConfig, webpackMiddleware: { - noInfo: true + stats: 'errors-only' }, singleRun: true }); diff --git a/package.json b/package.json index 385f89a..d0152cb 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "devDependencies": { "@commitlint/cli": "^7.0.0", "@commitlint/config-conventional": "^7.0.1", - "autoprefixer": "^7.1.2", + "autoprefixer": "^9.1.5", "babel-core": "^6.25.0", "babel-loader": "^7.1.1", "babel-plugin-istanbul": "^4.1.4", @@ -55,7 +55,7 @@ "eslint-loader": "^2.1.0", "eslint-plugin-import": "^2.14.0", "eslint-plugin-vue": "^4.7.1", - "html-webpack-plugin": "^2.30.1", + "html-webpack-plugin": "^3.2.0", "husky": "^0.14.3", "karma": "^3.0.0", "karma-chai": "^0.1.0", @@ -64,20 +64,20 @@ "karma-phantomjs-launcher": "^1.0.4", "karma-sinon-chai": "^1.3.1", "karma-spec-reporter": "0.0.31", - "karma-webpack": "^2.0.4", + "karma-webpack": "^4.0.0-rc.2", "less": "^3.8.1", "less-loader": "^4.1.0", "mocha": "^5.2.0", "phantomjs-prebuilt": "^2.1.15", + "postcss-loader": "^3.0.0", "sinon": "^2.4.1", "sinon-chai": "^2.13.0", - "style-loader": "^0.18.2", - "uglifyjs-webpack-plugin": "^0.4.6", - "vue": "^2.2.0", - "vue-loader": "^13.0.4", - "vue-template-compiler": "^2.4.2", - "webpack": "^3.5.4", - "webpack-dev-server": "^2.7.1" + "vue": "^2.5.17", + "vue-loader": "^15.4.1", + "vue-template-compiler": "^2.5.17", + "webpack": "^4.17.2", + "webpack-cli": "^3.1.0", + "webpack-dev-server": "^3.1.8" }, "peerDependencies": { "vue": "^2.2.0" diff --git a/webpack.config.js b/webpack.config.js index 90343b1..525c491 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,6 @@ const path = require('path'); const webpack = require('webpack'); +const VueLoaderPlugin = require('vue-loader/lib/plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { @@ -16,7 +17,7 @@ module.exports = { resolve: { extensions: ['.js', '.vue'], alias: { - 'vue$': 'vue/dist/vue.min.js' + vue$: 'vue/dist/vue.min.js' } }, module: { @@ -37,13 +38,36 @@ module.exports = { }, { test: /\.vue$/, - loader: 'vue-loader', - options: { - postcss: [require('autoprefixer')] - } + loader: 'vue-loader' + }, + { + test: /\.less$/, + use: [ + 'vue-style-loader', + { + loader: 'css-loader', + options: { + importLoaders: 2 + } + }, + { + loader: 'postcss-loader', + options: { + ident: 'postcss', + plugins: [ + require('autoprefixer') + ] + } + }, + 'less-loader' + ] } ] - } + }, + plugins: [ + new VueLoaderPlugin() + ], + mode: process.env.NODE_ENV || 'development' }; if (process.env.NODE_ENV === 'production') { @@ -55,18 +79,12 @@ if (process.env.NODE_ENV === 'production') { `${pkg.license} License` ].join('\n'); - module.exports.plugins = [ - new webpack.BannerPlugin(banner) - ]; + module.exports.plugins.push(new webpack.BannerPlugin(banner)); } else { // development configurations - module.exports.plugins = [ - new HtmlWebpackPlugin({ - filename: 'index.html', - template: './example/index.html', - inject: false - }) - ]; - - module.exports.devtool = '#cheap-module-eval-source-map'; + module.exports.plugins.push(new HtmlWebpackPlugin({ + filename: 'index.html', + template: './example/index.html', + inject: false + })); } From 719dcead745c846eff4f1bad145ed73a837dae67 Mon Sep 17 00:00:00 2001 From: Peach Date: Mon, 10 Sep 2018 14:08:29 +0800 Subject: [PATCH 012/152] build: upgrade babel to v7 --- .babelrc | 23 ----------------------- karma.conf.js | 1 - package.json | 12 ++++++------ webpack.config.js | 12 +++++++++++- 4 files changed, 17 insertions(+), 31 deletions(-) delete mode 100644 .babelrc diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 45b8019..0000000 --- a/.babelrc +++ /dev/null @@ -1,23 +0,0 @@ -{ - presets: [ - ['env', { - modules: false, - targets: { - browsers: [ - '> 1%', - 'last 1 versions', - 'last 4 Android versions', - 'last 3 iOS versions' - ] - } - }], - 'stage-2' - ], - plugins: ['transform-runtime'], - env: { - test: { - presets: ['env', 'stage-2'], - plugins: ['istanbul'] - } - } -} diff --git a/karma.conf.js b/karma.conf.js index 2cd440d..8bd552f 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,4 +1,3 @@ -const path = require('path'); const webpackConfig = require('./webpack.config'); delete webpackConfig.entry; diff --git a/package.json b/package.json index d0152cb..e76a09c 100644 --- a/package.json +++ b/package.json @@ -38,15 +38,15 @@ }, "homepage": "https://github.com/PeachScript/vue-infinite-loading", "devDependencies": { + "@babel/core": "^7.0.0", + "@babel/plugin-transform-runtime": "^7.0.0", + "@babel/preset-env": "^7.0.0", + "@babel/runtime": "^7.0.0", "@commitlint/cli": "^7.0.0", "@commitlint/config-conventional": "^7.0.1", "autoprefixer": "^9.1.5", - "babel-core": "^6.25.0", - "babel-loader": "^7.1.1", - "babel-plugin-istanbul": "^4.1.4", - "babel-plugin-transform-runtime": "^6.23.0", - "babel-preset-env": "^1.6.0", - "babel-preset-stage-2": "^6.24.1", + "babel-loader": "^8.0.2", + "babel-plugin-istanbul": "^5.0.1", "chai": "^3.5.0", "css-loader": "^0.28.4", "eslint": "^4.19.1", diff --git a/webpack.config.js b/webpack.config.js index 525c491..0240846 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -34,7 +34,17 @@ module.exports = { { test: /\.js$/, include: [path.join(__dirname, './src'), path.join(__dirname, './test')], - loader: 'babel-loader' + loader: 'babel-loader', + options: { + presets: ['@babel/preset-env'], + plugins: ['@babel/plugin-transform-runtime'], + env: { + test: { + presets: [['@babel/preset-env', { useBuiltIns: 'usage' }]], + plugins: ['babel-plugin-istanbul'] + } + } + } }, { test: /\.vue$/, From 12790959628ad0fa9a3e61f6696b8a54c1b5a5d6 Mon Sep 17 00:00:00 2001 From: Peach Date: Mon, 10 Sep 2018 14:16:22 +0800 Subject: [PATCH 013/152] build: modify commit msg for release script --- release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index 9a4655c..dfa776e 100644 --- a/release.sh +++ b/release.sh @@ -17,8 +17,8 @@ then # commit git add -A - git commit -m "Build for $VERSION" - npm version $VERSION -m "Upgrade to $VERSION" + git commit -m "build: build $VERSION" + npm version $VERSION -m "build: release $VERSION" # publish npm publish From a88ffb776878a07cb2f349bc3dd8cce59932b7e1 Mon Sep 17 00:00:00 2001 From: Peach Date: Tue, 11 Sep 2018 11:28:55 +0800 Subject: [PATCH 014/152] docs: add code of conduct --- .github/CODE_OF_CONDUCT.md | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/CODE_OF_CONDUCT.md diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..dc54ab1 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at [scdzwyxst@gmail.com](mailto:scdzwyxst@gmail.com). All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org From 1e10646409a60b2c696bad09953c12df3909c687 Mon Sep 17 00:00:00 2001 From: Peach Date: Tue, 11 Sep 2018 17:01:43 +0800 Subject: [PATCH 015/152] docs: add commit convention --- .github/COMMIT_CONVENTION.md | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/COMMIT_CONVENTION.md diff --git a/.github/COMMIT_CONVENTION.md b/.github/COMMIT_CONVENTION.md new file mode 100644 index 0000000..ccd11a6 --- /dev/null +++ b/.github/COMMIT_CONVENTION.md @@ -0,0 +1,91 @@ +## Git Commit Message Convention + +> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular). + +#### TL;DR: + +Messages must be matched by the following regex: + +``` js +/^(revert: )?(build|chore|ci|docs|feat|fix|perf|refactor|style|test)(\((core|config|spinner|deps)\))?: .{1,72}$/ +``` + +#### Examples + +Appears under "Features" header, `core` subheader: + +``` +feat(core): support top direction +``` + +Appears under "Bug Fixes" header, `spinner` subheader, with a link to issue #28: + +``` +fix(spinner): animation compatibility + +close #28 +``` + +Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation: + +``` +perf(core): use @infinite event instead of on-infinite property + +BREAKING CHANGE: The 'on-infinite' property has been removed. +``` + +The following commit and commit `a88ffb7` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header. + +``` +revert: feat(core): support top direction + +This reverts commit a88ffb776878a07cb2f349bc3dd8cce59932b7e1. +``` + +### Full Message Format + +A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: + +``` +(): + + + +