66.afd0af7d.js 3.2 KB

1
  1. (window.webpackJsonp=window.webpackJsonp||[]).push([[66],{538:function(t,s,e){},701:function(t,s,e){"use strict";e(538)},726:function(t,s,e){"use strict";e.r(s);var o=e(436),r=e(435),n=function(){function t(t){this.scroll=t,this.stopObserver=!1,this.init()}return t.prototype.init=function(){this.handleMutationObserver(),this.handleHooks()},t.prototype.handleMutationObserver=function(){var t=this;if("undefined"!=typeof MutationObserver){this.observer=new MutationObserver((function(s){t.mutationObserverHandler(s,0)})),this.startObserve(this.observer)}else this.checkDOMUpdate()},t.prototype.handleHooks=function(){var t=this;this.hooksFn=[],this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.contentChanged,(function(){t.stopObserve(),t.handleMutationObserver()})),this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.enable,(function(){t.stopObserver&&t.handleMutationObserver()})),this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.disable,(function(){t.stopObserve()})),this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.destroy,(function(){t.destroy()}))},t.prototype.mutationObserverHandler=function(t,s){var e=this;if(!this.shouldNotRefresh()){for(var o=!1,r=!1,n=0;n<t.length;n++){var i=t[n];if("attributes"!==i.type){o=!0;break}if(i.target!==this.scroll.scroller.content){r=!0;break}}o?this.scroll.refresh():r&&(clearTimeout(s),s=window.setTimeout((function(){e.shouldNotRefresh()||e.scroll.refresh()}),60))}},t.prototype.startObserve=function(t){t.observe(this.scroll.scroller.content,{attributes:!0,childList:!0,subtree:!0})},t.prototype.shouldNotRefresh=function(){var t=this.scroll.scroller,s=t.scrollBehaviorX,e=t.scrollBehaviorY,o=s.currentPos>s.minScrollPos||s.currentPos<s.maxScrollPos||e.currentPos>e.minScrollPos||e.currentPos<e.maxScrollPos;return t.animater.pending||o},t.prototype.checkDOMUpdate=function(){var t=this,s=this.scroll.scroller.content,e=Object(r.z)(s),o=e.width,n=e.height,i=function(){setTimeout((function(){!function(){if(!t.stopObserver){var l=(e=Object(r.z)(s)).width,c=e.height;o===l&&n===c||t.scroll.refresh(),o=l,n=c,i()}}()}),1e3)};i()},t.prototype.registerHooks=function(t,s,e){t.on(s,e,this),this.hooksFn.push([t,s,e])},t.prototype.stopObserve=function(){this.stopObserver=!0,this.observer&&this.observer.disconnect()},t.prototype.destroy=function(){this.stopObserve(),this.hooksFn.forEach((function(t){var s=t[0],e=t[1],o=t[2];s.off(e,o)})),this.hooksFn.length=0},t.pluginName="observeDOM",t}();o.a.use(n);var i={data:function(){return{nums:10}},mounted:function(){this.init()},beforeDestroy:function(){this.bs.destroy()},methods:{init:function(){this.bs=new o.a(this.$refs.scroll,{observeDOM:!0,scrollX:!0,scrollY:!1})},handleClick:function(){this.nums+=2}}},l=(e(701),e(41)),c=Object(l.a)(i,(function(){var t=this,s=t._self._c;return s("div",{staticClass:"observe-dom-container"},[s("div",{ref:"scroll",staticClass:"scroll-wrapper"},[s("div",{staticClass:"scroll-content"},t._l(t.nums,(function(e){return s("div",{key:e,staticClass:"scroll-item"},[t._v(t._s(t.nums-e+1))])})),0)]),t._v(" "),s("button",{staticClass:"btn",on:{click:t.handleClick}},[t._v("append two children element")])])}),[],!1,null,"08e39caf",null);s.default=c.exports}}]);