minirefresh.theme.taobao.min.js 6 KB
/*!
 * minirefresh v2.0.2
 * (c) 2017-2018 dailc
 * Released under the MIT License.
 * https://github.com/minirefresh/minirefresh
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.MiniRefresh=e()}(this,function(){"use strict";var t=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),e=MiniRefreshTools.theme.defaults,n=MiniRefreshTools.version,o=MiniRefreshTools.extend,s=MiniRefreshTools.namespace,r="minirefresh-hidden",a={down:{offset:100,dampRate:.4,successAnim:{isEnable:!1},secretGarden:{isEnable:!0,offset:200,tips:"欢迎光临秘密花园",inSecretGarden:null},isWrapCssTranslate:!0}},i=function(n){function s(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s);var e=o(!0,{},a,t);return function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(s,e),t(s,[{key:"_initDownWrap",value:function(){var t=this.container,n=this.contentWrap,o=document.createElement("div");o.className="minirefresh-downwrap minirefresh-hardware-speedup",o.innerHTML=' \n            <div class="downwrap-bg"></div>\n            <div class="downwrap-moon"></div>\n            <div class="downwrap-content">\n                <p class="downwrap-progress"></p>\n                <p class="downwrap-tips">'+this.options.down.contentdown+"</p>\n            </div>\n        ",t.insertBefore(o,n),t.classList.add("minirefresh-theme-taobao"),this.downWrap=o,this.downWrapProgress=this.downWrap.querySelector(".downwrap-progress"),this.downWrapTips=this.downWrap.querySelector(".downwrap-tips"),this.downWrapBg=this.downWrap.querySelector(".downwrap-bg"),this.downWrapMoon=this.downWrap.querySelector(".downwrap-moon"),this.pullState=0,this.downWrapHeight=this.downWrap.offsetHeight||800,this._transformDownWrap(-1*this.downWrapHeight),e._changeWrapStatusClass(this.downWrap,"status-default")}},{key:"_transformDownWrap",value:function(t,e){(function t(e,n,o){null===e&&(e=Function.prototype);var s=Object.getOwnPropertyDescriptor(e,n);if(void 0===s){var r=Object.getPrototypeOf(e);return null===r?void 0:t(r,n,o)}if("value"in s)return s.value;var a=s.get;if(void 0!==a)return a.call(o)})(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_transformDownWrap",this).call(this,t,e)}},{key:"_rotateDownProgress",value:function(t){var e="rotate("+t+"deg)";this.downWrapProgress.style.webkitTransform=e,this.downWrapProgress.style.transform=e}},{key:"_pullHook",value:function(t,n){var o=this.options.down,s=o.secretGarden.isEnable,a=o.secretGarden.offset,i=360*(t/n);this._transformDownWrap(-this.downWrapHeight+t),this._rotateDownProgress(i),t<n?1!==this.pullState&&(this.downWrapBg.classList.remove("secret-garden-bg-out"),this.downWrapMoon.classList.remove("secret-garden-moon-out"),this.downWrapTips.classList.remove(r),this.downWrapProgress.classList.remove(r),this.downWrapTips.innerText=o.contentdown,this.pullState=1,e._changeWrapStatusClass(this.downWrap,"status-default")):t>=n&&(!s||t<a)?2!==this.pullState&&(this.downWrapTips.classList.remove(r),this.downWrapProgress.classList.remove(r),this.downWrapTips.innerText=o.contentover,this.pullState=2,e._changeWrapStatusClass(this.downWrap,"status-pull")):3!==this.pullState&&(this.downWrapTips.classList.remove(r),this.downWrapProgress.classList.add(r),this.downWrapTips.innerText=o.secretGarden.tips,this.pullState=3)}},{key:"_beforeDownLoadingHook",value:function(){return 3!==this.pullState||(this._inSecretGarden(),!1)}},{key:"_downLoaingHook",value:function(){this.downWrapTips.innerText=this.options.down.contentrefresh,this.downWrapProgress.classList.add("minirefresh-rotate"),this._transformDownWrap(-this.downWrapHeight+this.options.down.offset,this.options.down.bounceTime),e._changeWrapStatusClass(this.downWrap,"status-loading")}},{key:"_downLoaingSuccessHook",value:function(t){e._changeWrapStatusClass(this.downWrap,t?"status-success":"status-error")}},{key:"_downLoaingEndHook",value:function(){this.downWrapTips.innerText=this.options.down.contentdown,this.downWrapProgress.classList.remove("minirefresh-rotate"),this._transformDownWrap(-this.downWrapHeight,this.options.down.bounceTime),this.pullState=0,e._changeWrapStatusClass(this.downWrap,"status-default")}},{key:"_cancelLoaingHook",value:function(){this._transformDownWrap(-this.downWrapHeight,this.options.down.bounceTime),this.pullState=0,e._changeWrapStatusClass(this.downWrap,"status-default")}},{key:"_secretGardenAnimation",value:function(t){var e=t?"secret-garden-bg-in":"secret-garden-bg-out",n=t?"secret-garden-bg-out":"secret-garden-bg-in",o=t?"secret-garden-moon-in":"secret-garden-moon-out",s=t?"secret-garden-moon-out":"secret-garden-moon-in";this.downWrapBg.classList.remove(n),this.downWrapBg.classList.add(e),this.downWrapMoon.classList.remove(s),this.downWrapMoon.classList.add(o)}},{key:"_inSecretGarden",value:function(){var t=this.options.down.bounceTime,e=this.options.down.secretGarden.inSecretGarden,n=document.documentElement.clientHeight;this.downWrapTips.classList.add(r),this.scroller.translateContentWrap(n,t),this._transformDownWrap(n-this.downWrapHeight,t),this._secretGardenAnimation(!0),e&&e()}},{key:"resetSecretGarden",value:function(){var t=this.options.down.bounceTime;this.scroller.translateContentWrap(0,t),this._transformDownWrap(-1*this.downWrapHeight,t),this._secretGardenAnimation(!1),this.pullState=0}}]),s}();return i.sign="taobao",i.version=n,s("theme.taobao",i),i});