eeeeeeuuuu-ui
Version:
uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水
12 lines (11 loc) • 3.81 kB
JavaScript
require('../../../app.js');
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["uview-ui/components/u-index-list/u-index-list"],{"383d":function(t,e,i){},"8cbc":function(t,e,i){"use strict";(function(t){var i=function(){for(var t=[],e="A".charCodeAt(0),i=0;i<26;i++)t.push(String.fromCharCode(e+i));return t};e["a"]={name:"u-index-list",props:{sticky:{type:Boolean,default:!0},zIndex:{type:[Number,String],default:""},scrollTop:{type:[Number,String],default:0},offsetTop:{type:[Number,String],default:0},indexList:{type:Array,default(){return i()}},activeColor:{type:String,default:"#2979ff"}},created(){this.stickyOffsetTop=this.offsetTop?t.upx2px(this.offsetTop):0,this.children=[]},provide(){return{UIndexList:this}},data(){return{activeAnchorIndex:0,showSidebar:!0,touchmove:!1,touchmoveIndex:0}},watch:{scrollTop(){this.updateData()}},computed:{alertZIndex(){return this.$u.zIndex.toast}},methods:{updateData(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.showSidebar=!!this.children.length,this.setRect().then(()=>{this.onScroll()})},0)},setRect(){return Promise.all([this.setAnchorsRect(),this.setListRect(),this.setSiderbarRect()])},setAnchorsRect(){return Promise.all(this.children.map((t,e)=>t.$uGetRect(".u-index-anchor-wrapper").then(e=>{Object.assign(t,{height:e.height,top:e.top})})))},setListRect(){return this.$uGetRect(".u-index-bar").then(t=>{Object.assign(this,{height:t.height,top:t.top+this.scrollTop})})},setSiderbarRect(){return this.$uGetRect(".u-index-bar__sidebar").then(t=>{this.sidebar={height:t.height,top:t.top}})},getActiveAnchorIndex(){const{children:t}=this,{sticky:e}=this;for(let i=this.children.length-1;i>=0;i--){const o=i>0?t[i-1].height:0,s=e?o:0;if(s>=t[i].top)return i}return-1},onScroll(){const{children:t=[]}=this;if(!t.length)return;const{sticky:e,stickyOffsetTop:i,zIndex:o,scrollTop:s,activeColor:r}=this,n=this.getActiveAnchorIndex();if(this.activeAnchorIndex=n,e){let e=!1;-1!==n&&(e=t[n].top<=0),t.forEach((s,h)=>{if(h===n){let c="",l={color:""+r};e&&(c={height:t[h].height+"px"},l={position:"fixed",top:i+"px",zIndex:""+(o||this.$u.zIndex.indexListSticky),color:""+r}),s.active=n,s.wrapperStyle=c,s.anchorStyle=l}else if(h===n-1){const e=t[h],i=e.top,c=h===t.length-1?this.top:t[h+1].top,l=c-i,a=l-e.height,d={position:"relative",transform:`translate3d(0, ${a}px, 0)`,zIndex:""+(o||this.$u.zIndex.indexListSticky),color:""+r};s.active=n,s.anchorStyle=d}else s.active=!1,s.anchorStyle="",s.wrapperStyle=""})}},onTouchMove(t){this.touchmove=!0;const e=this.children.length,i=t.touches[0],o=this.sidebar.height/e;let s=0;s=i.clientY;let r=Math.floor((s-this.sidebar.top)/o);r<0?r=0:r>e-1&&(r=e-1),this.touchmoveIndex=r,this.scrollToAnchor(r)},onTouchStop(){this.touchmove=!1,this.scrollToAnchorIndex=null},scrollToAnchor(e){if(this.scrollToAnchorIndex===e)return;this.scrollToAnchorIndex=e;const i=this.children.find(t=>t.index===this.indexList[e]);i&&(this.$emit("select",i.index),t.pageScrollTo({duration:0,scrollTop:i.top+this.scrollTop}))}}}}).call(this,i("543d")["default"])},a667:function(t,e,i){"use strict";var o=i("383d"),s=i.n(o);s.a},cd15:function(t,e,i){"use strict";var o;i.r(e);var s,r=function(){var t=this,e=t.$createElement;t._self._c},n=[],h=i("8cbc"),c=h["a"],l=(i("a667"),i("f0c5")),a=Object(l["a"])(c,r,n,!1,null,"648935f9",null,!1,o,s);e["default"]=a.exports}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
'uview-ui/components/u-index-list/u-index-list-create-component',
{
'uview-ui/components/u-index-list/u-index-list-create-component':(function(module, exports, __webpack_require__){
__webpack_require__('543d')['createComponent'](__webpack_require__("cd15"))
})
},
[['uview-ui/components/u-index-list/u-index-list-create-component']]
]);