UNPKG

4.64 kBJavaScriptView Raw
1module.exports=function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,e),s.l=!0,s.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="/dist/",e(e.s=295)}({0:function(t,e){t.exports=function(t,e,i,n,s,r){var o,a=t=t||{},c=typeof t.default;"object"!==c&&"function"!==c||(o=t,a=t.default);var l="function"==typeof a?a.options:a;e&&(l.render=e.render,l.staticRenderFns=e.staticRenderFns,l._compiled=!0),i&&(l.functional=!0),s&&(l._scopeId=s);var u;if(r?(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__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(r)},l._ssrRegister=u):n&&(u=n),u){var d=l.functional,f=d?l.render:l.beforeCreate;d?(l._injectStyles=u,l.render=function(t,e){return u.call(e),f(t,e)}):l.beforeCreate=f?[].concat(f,u):[u]}return{esModule:o,exports:a,options:l}}},113:function(t,e,i){"use strict";var n=i(23),s=i.n(n);e.a={name:"IndexList",componentName:"IndexList",props:{data:{type:Array}},data:function(){var t=this.data.map(function(t){return t.label.charAt(0)});return{navList:t,currentCharAt:t[0]}},watch:{data:function(t){var e=t.map(function(t){return t.label.charAt(0)});this.navList=e,this.currentCharAt=e[0]}},updated:function(){this.$nextTick(this.init)},mounted:function(){this.init(),!this.supportSticky()&&window.addEventListener("resize",this.handleResize,!1)},beforeDestroy:function(){!this.supportSticky()&&window.removeEventListener("resize",this.handleResize)},methods:{init:function(){this.$$scrollNode=this.$el.querySelector(".vx-index-list--each"),this.$$titleNodes=s()(this.$el.querySelectorAll(".vx-index-list--title")),this.$$titleNodes.forEach(function(t){t._offsetTop=t.offsetTop}),this.$$navNodes=s()(this.$el.querySelectorAll(".vx-index-list--nav div")),this.$$fixedNode=this.$el.querySelector(".vx-index-list--fixed"),this.supportSticky()||(this.$$fixedNode.style.display="none"),this.$$Y=this.$$fixedNode.offsetHeight},supportSticky:function(){if(void 0!==this.$$supportSticky)return this.$$supportSticky;var t=document.createElement("div");return t.style.cssText="position:-webkit-sticky;position:sticky;",this.$$supportSticky=(t.style.cssText||"").indexOf("sticky")>-1,this.$$supportSticky},activeNavItem:function(t){var e=this.$$navNodes[t];this.$$navNodes.forEach(function(t){e===t?requestAnimationFrame(function(){t.classList.add("is-active")}):requestAnimationFrame(function(){t.classList.remove("is-active")})})},handleScroll:function(){var t=this,e=this.$$scrollNode.scrollTop;this.$$titleNodes.forEach(function(i,n){var s=i._offsetTop-e;s<t.$$Y&&s>0?!t.supportSticky()&&requestAnimationFrame(function(){t.$$fixedNode.style.top="-"+(t.$$Y-s-1)+"px"}):s<=0&&(!t.supportSticky()&&requestAnimationFrame(function(){t.$$fixedNode.style.top="",t.$$fixedNode.innerHTML=i.innerHTML.charAt(0)}),t.activeNavItem(n))})},handleResize:function(){this.init(),this.handleScroll()},handleGroup:function(t){var e=this.$$titleNodes[t];e.offsetParent.scrollTop=e._offsetTop},handleClick:function(t){this.$emit("click",t)}}}},214:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(113),s=i(215),r=i(0),o=r(n.a,s.a,!1,null,null,null);e.default=o.exports},215:function(t,e,i){"use strict";var n=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"vx-index-list"},[i("div",{staticClass:"vx-index-list--each",on:{scroll:t.handleScroll}},[t._l(t.data,function(e,n){return[i("div",{key:n+"title",staticClass:"vx-index-list--title"},[t._v(t._s(e.label))]),i("div",{key:n+"group",staticClass:"vx-index-list--group"},t._l(e.items,function(e,n){return i("div",{key:n,staticClass:"vx-index-list--item",on:{click:function(i){t.handleClick(e.value)}}},[t.$slots.default?t._t("default"):t._e(),[t._v(t._s(e.label))]],2)}))]})],2),i("div",{staticClass:"vx-index-list--nav"},t._l(t.navList,function(e,n){return i("div",{key:n,class:{"is-active":0===n},on:{click:function(e){t.handleGroup(n)}}},[t._v(t._s(e))])})),i("div",{staticClass:"vx-index-list--fixed"},[t._v(t._s(t.currentCharAt||" "))])])},s=[],r={render:n,staticRenderFns:s};e.a=r},23:function(t,e){t.exports=require("babel-runtime/core-js/array/from")},295:function(t,e,i){t.exports=i(214)}});
\No newline at end of file