UNPKG

wux-weapp

Version:

一套组件化、可复用、易扩展的微信小程序 UI 组件库

1 lines 1.3 kB
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/libs/classNames")),_useDOM=require("../helpers/hooks/useDOM");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(0,_baseComponent.default)({relations:{"../sticky/index":{type:"parent"}},properties:{prefixCls:{type:String,value:"wux-sticky-item"},title:{type:String,value:""},content:{type:String,value:""}},data:{isFixed:!1,index:0,top:0,height:0},computed:{classes:["prefixCls, isFixed",function(e,t){return{wrap:(0,_classNames2.default)(e,_defineProperty({},"".concat(e,"--fixed"),t)),hd:"".concat(e,"__hd"),title:"".concat(e,"__title"),bd:"".concat(e,"__bd"),content:"".concat(e,"__content")}}]},methods:{onScroll:function(e){var t=this.getRelationsByName("../sticky/index")[0],i=this.data,n=i.top,s=i.height,a=i.index,r=n<=e&&e<n+s;this.data.isFixed!==r&&(this.setData({isFixed:r}),t&&t.triggerEvent(r?"stick":"unstick",{index:a}))},updated:function(t){var i=this;(0,_useDOM.useRect)(".".concat(this.data.prefixCls),this).then(function(e){e&&i.setData({top:e.top,height:e.height,index:t})})}}});