"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 _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,i){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0===i)return("string"===t?String:Number)(e);i=i.call(e,t||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}(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,r=i.top,n=i.height,i=i.index,e=r<=e&&e<r+n;this.data.isFixed!==e&&(this.setData({isFixed:e}),t)&&t.triggerEvent(e?"stick":"unstick",{index:i})},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})})}}});