28.22550ea8.js 11 KB

1
  1. (window.webpackJsonp=window.webpackJsonp||[]).push([[28],{444:function(o,t,s){"use strict";var l=s(435),e=[{key:"finishPullUp",name:"finishPullUp"},{key:"openPullUp",name:"openPullUp"},{key:"closePullUp",name:"closePullUp"},{key:"autoPullUpLoad",name:"autoPullUpLoad"}].map((function(o){return{key:o.key,sourceKey:"plugins.pullUpLoad."+o.name}})),i=function(){function o(o){this.scroll=o,this.pulling=!1,this.watching=!1,this.init()}return o.prototype.init=function(){this.handleBScroll(),this.handleOptions(this.scroll.options.pullUpLoad),this.handleHooks(),this.watch()},o.prototype.handleBScroll=function(){this.scroll.registerType(["pullingUp"]),this.scroll.proxy(e)},o.prototype.handleOptions=function(o){void 0===o&&(o={}),o=!0===o?{}:o;this.options=Object(l.t)({threshold:0},o),this.scroll.options.probeType=l.j.Realtime},o.prototype.handleHooks=function(){var o=this;this.hooksFn=[];var t=this.scroll.scroller.scrollBehaviorY;this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.contentChanged,(function(){o.finishPullUp()})),this.registerHooks(t.hooks,t.hooks.eventTypes.computeBoundary,(function(o){o.maxScrollPos>0&&(o.maxScrollPos=-1)}))},o.prototype.registerHooks=function(o,t,s){o.on(t,s,this),this.hooksFn.push([o,t,s])},o.prototype.watch=function(){this.watching||(this.watching=!0,this.registerHooks(this.scroll,this.scroll.eventTypes.scroll,this.checkPullUp))},o.prototype.unwatch=function(){this.watching=!1,this.scroll.off(this.scroll.eventTypes.scroll,this.checkPullUp)},o.prototype.checkPullUp=function(o){var t=this,s=this.options.threshold;this.scroll.movingDirectionY===l.b.Positive&&o.y<=this.scroll.maxScrollY+s&&(this.pulling=!0,this.scroll.once(this.scroll.eventTypes.scrollEnd,(function(){t.pulling=!1})),this.unwatch(),this.scroll.trigger("pullingUp"))},o.prototype.finishPullUp=function(){var o=this;this.scroll.scroller.scrollBehaviorY.setMovingDirection(l.b.Default),this.pulling?this.scroll.once(this.scroll.eventTypes.scrollEnd,(function(){o.watch()})):this.watch()},o.prototype.openPullUp=function(o){void 0===o&&(o={}),this.handleOptions(o),this.watch()},o.prototype.closePullUp=function(){this.unwatch()},o.prototype.autoPullUpLoad=function(){var o=this.options.threshold,t=this.scroll.scroller.scrollBehaviorY;if(!this.pulling&&this.watching){var s=t.maxScrollPos+o+-1;this.scroll.scroller.scrollBehaviorY.setMovingDirection(-1),this.scroll.scrollTo(this.scroll.x,s,this.scroll.options.bounceTime)}},o.pluginName="pullUpLoad",o}();t.a=i},445:function(o,t,s){"use strict";var l,e,i=s(435),n=[{key:"finishPullDown",name:"finishPullDown"},{key:"openPullDown",name:"openPullDown"},{key:"closePullDown",name:"closePullDown"},{key:"autoPullDownRefresh",name:"autoPullDownRefresh"}].map((function(o){return{key:o.key,sourceKey:"plugins.pullDownRefresh."+o.name}}));!function(o){o[o.DEFAULT=0]="DEFAULT",o[o.MOVING=1]="MOVING",o[o.FETCHING=2]="FETCHING"}(l||(l={})),function(o){o[o.DEFAULT=0]="DEFAULT",o[o.INSIDE=1]="INSIDE",o[o.OUTSIDE=2]="OUTSIDE"}(e||(e={}));var r=function(){function o(o){this.scroll=o,this.pulling=l.DEFAULT,this.thresholdBoundary=e.DEFAULT,this.init()}return o.prototype.setPulling=function(o){this.pulling=o},o.prototype.setThresholdBoundary=function(o){this.thresholdBoundary=o},o.prototype.init=function(){this.handleBScroll(),this.handleOptions(this.scroll.options.pullDownRefresh),this.handleHooks(),this.watch()},o.prototype.handleBScroll=function(){this.scroll.registerType(["pullingDown","enterThreshold","leaveThreshold"]),this.scroll.proxy(n)},o.prototype.handleOptions=function(o){void 0===o&&(o={}),o=!0===o?{}:o;this.options=Object(i.t)({threshold:90,stop:40},o),this.scroll.options.probeType=i.j.Realtime},o.prototype.handleHooks=function(){var o=this;this.hooksFn=[];var t=this.scroll.scroller,s=t.scrollBehaviorY;this.currentMinScrollY=this.cachedOriginanMinScrollY=s.minScrollPos,this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.contentChanged,(function(){o.finishPullDown()})),this.registerHooks(s.hooks,s.hooks.eventTypes.computeBoundary,(function(t){t.maxScrollPos>0&&(t.maxScrollPos=-1),t.minScrollPos=o.currentMinScrollY})),this.hasMouseWheelPlugin()&&(this.registerHooks(this.scroll,this.scroll.eventTypes.alterOptions,(function(o){o.discreteTime=300,o.easeTime=350})),this.registerHooks(this.scroll,this.scroll.eventTypes.mousewheelEnd,(function(){t.hooks.trigger(t.hooks.eventTypes.end)})))},o.prototype.registerHooks=function(o,t,s){o.on(t,s,this),this.hooksFn.push([o,t,s])},o.prototype.hasMouseWheelPlugin=function(){return!!this.scroll.eventTypes.alterOptions},o.prototype.watch=function(){var o=this.scroll.scroller;this.watching=!0,this.registerHooks(o.hooks,o.hooks.eventTypes.end,this.checkPullDown),this.registerHooks(this.scroll,this.scroll.eventTypes.scrollStart,this.resetStateBeforeScrollStart),this.registerHooks(this.scroll,this.scroll.eventTypes.scroll,this.checkLocationOfThresholdBoundary),this.hasMouseWheelPlugin()&&this.registerHooks(this.scroll,this.scroll.eventTypes.mousewheelStart,this.resetStateBeforeScrollStart)},o.prototype.resetStateBeforeScrollStart=function(){this.isFetchingStatus()||(this.setPulling(l.MOVING),this.setThresholdBoundary(e.DEFAULT))},o.prototype.checkLocationOfThresholdBoundary=function(){if(this.pulling===l.MOVING){var o=this.scroll,t=this.thresholdBoundary!==e.INSIDE&&this.locateInsideThresholdBoundary(),s=this.thresholdBoundary!==e.OUTSIDE&&!this.locateInsideThresholdBoundary();t&&(this.setThresholdBoundary(e.INSIDE),o.trigger("enterThreshold")),s&&(this.setThresholdBoundary(e.OUTSIDE),o.trigger("leaveThreshold"))}},o.prototype.locateInsideThresholdBoundary=function(){return this.scroll.y<=this.options.threshold},o.prototype.unwatch=function(){var o=this.scroll,t=o.scroller;this.watching=!1,t.hooks.off(t.hooks.eventTypes.end,this.checkPullDown),o.off(o.eventTypes.scrollStart,this.resetStateBeforeScrollStart),o.off(o.eventTypes.scroll,this.checkLocationOfThresholdBoundary),this.hasMouseWheelPlugin()&&o.off(o.eventTypes.mousewheelStart,this.resetStateBeforeScrollStart)},o.prototype.checkPullDown=function(){var o=this.options,t=o.threshold,s=o.stop;return!(this.scroll.y<t)&&(this.pulling===l.MOVING&&(this.modifyBehaviorYBoundary(s),this.setPulling(l.FETCHING),this.scroll.trigger("pullingDown")),this.scroll.scrollTo(this.scroll.x,s,this.scroll.options.bounceTime,i.r.bounce),this.isFetchingStatus())},o.prototype.isFetchingStatus=function(){return this.pulling===l.FETCHING},o.prototype.modifyBehaviorYBoundary=function(o){var t=this.scroll.scroller.scrollBehaviorY;this.cachedOriginanMinScrollY=t.minScrollPos,this.currentMinScrollY=o,t.computeBoundary()},o.prototype.finishPullDown=function(){if(this.isFetchingStatus()){var o=this.scroll.scroller.scrollBehaviorY;this.currentMinScrollY=this.cachedOriginanMinScrollY,o.computeBoundary(),this.setPulling(l.DEFAULT),this.scroll.resetPosition(this.scroll.options.bounceTime,i.r.bounce)}},o.prototype.openPullDown=function(o){void 0===o&&(o={}),this.handleOptions(o),this.watching||this.watch()},o.prototype.closePullDown=function(){this.unwatch()},o.prototype.autoPullDownRefresh=function(){var o=this.options,t=o.threshold,s=o.stop;!this.isFetchingStatus()&&this.watching&&(this.modifyBehaviorYBoundary(s),this.scroll.trigger(this.scroll.eventTypes.scrollStart),this.scroll.scrollTo(this.scroll.x,t),this.setPulling(l.FETCHING),this.scroll.trigger("pullingDown"),this.scroll.scrollTo(this.scroll.x,s,this.scroll.options.bounceTime,i.r.bounce))},o.pluginName="pullDownRefresh",o}();t.a=r},510:function(o,t,s){},583:function(o,t,s){"use strict";s(510)},735:function(o,t,s){"use strict";s.r(t);var l=s(44),e=s(85),i=(s(252),s(11),s(436)),n=s(445),r=s(444);i.a.use(n.a),i.a.use(r.a);var h={data:function(){return{beforePullDown:!0,isPullingDown:!1,isPullingUp:!1,dataList:new Array(30)}},created:function(){this.bscroll=null},mounted:function(){this.initBscroll()},methods:{initBscroll:function(){this.bscroll=new i.a(this.$refs.bsWrapper,{scrollY:!0,bounceTime:800,pullDownRefresh:{threshold:70,stop:56},pullUpLoad:{threshold:70}}),this.bscroll.on("pullingDown",this.pullingDownHandler),this.bscroll.on("pullingUp",this.pullingUpHandler),this.bscroll.on("scroll",this.scrollHandler)},scrollHandler:function(o){console.log(o.y)},pullingDownHandler:function(){var o=this;return Object(e.a)(Object(l.a)().mark((function t(){return Object(l.a)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o.beforePullDown=!1,o.isPullingDown=!0,t.next=4,o.requestData("refresh");case 4:o.isPullingDown=!1,o.$nextTick((function(){o.bscroll.finishPullDown(),o.beforePullDown=!0,o.bscroll.refresh()}));case 6:case"end":return t.stop()}}),t)})))()},pullingUpHandler:function(){var o=this;return Object(e.a)(Object(l.a)().mark((function t(){return Object(l.a)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o.isPullingUp=!0,t.next=3,o.requestData("load");case 3:o.isPullingUp=!1,o.$nextTick((function(){o.bscroll.finishPullUp(),o.bscroll.refresh()}));case 5:case"end":return t.stop()}}),t)})))()},requestData:function(o){var t=this;return Object(e.a)(Object(l.a)().mark((function s(){var e;return Object(l.a)().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.prev=0,s.next=3,t.ajaxGet();case 3:e=s.sent,t.dataList="load"===o?e.concat(t.dataList):e,s.next=10;break;case 7:s.prev=7,s.t0=s.catch(0),console.log(s.t0);case 10:case"end":return s.stop()}}),s,null,[[0,7]])})))()},ajaxGet:function(){return new Promise((function(o){setTimeout((function(){var t=new Array(30);o(t)}),3e3)}))}}},c=(s(583),s(41)),a=Object(c.a)(h,(function(){var o=this,t=o._self._c;return t("div",{staticClass:"pullup-down"},[t("div",{ref:"bsWrapper",staticClass:"pullup-down-bswrapper"},[t("div",{staticClass:"pulldown-scroller"},[t("div",{staticClass:"pulldown-wrapper"},[t("div",{directives:[{name:"show",rawName:"v-show",value:o.beforePullDown,expression:"beforePullDown"}]},[t("span",[o._v("Pull Down and refresh")])]),o._v(" "),t("div",{directives:[{name:"show",rawName:"v-show",value:!o.beforePullDown,expression:"!beforePullDown"}]},[t("div",{directives:[{name:"show",rawName:"v-show",value:o.isPullingDown,expression:"isPullingDown"}]},[t("span",[o._v("Loading...")])]),o._v(" "),t("div",{directives:[{name:"show",rawName:"v-show",value:!o.isPullingDown,expression:"!isPullingDown"}]},[t("span",[o._v("Refresh success")])])])]),o._v(" "),t("ul",{staticClass:"pullup-down-list"},o._l(o.dataList,(function(s,l){return t("li",{key:l,staticClass:"pullup-down-list-item"},[o._v(o._s("I am item ".concat(l," ")))])})),0),o._v(" "),t("div",{staticClass:"pullup-wrapper"},[t("div",{directives:[{name:"show",rawName:"v-show",value:!o.isPullingUp,expression:"!isPullingUp"}]},[t("span",[o._v("Pull Up and load")])]),o._v(" "),t("div",{directives:[{name:"show",rawName:"v-show",value:o.isPullingUp,expression:"isPullingUp"}]},[t("span",[o._v("Loading...")])])])])])])}),[],!1,null,"b47bb5b8",null);t.default=a.exports}}]);