UNPKG

shu-c-view

Version:

rollup 打包vue@2.7组件库框架

7 lines (6 loc) 3.65 kB
/*! * shu-c-view v2.0.0 * (c) 2024-04-23 * @license MIT */ "use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("vue")).prototype.$isServer,o=!e&&document.addEventListener?function(t,e,o){var s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];t&&e&&o&&t.addEventListener(e,o,s)}:function(t,e,o){t&&e&&o&&t.attachEvent("on".concat(e),o)},s=!e&&document.removeEventListener?function(t,e,o){var s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];t&&e&&t.removeEventListener(e,o,s)}:function(t,e,o){t&&e&&t.detachEvent("on".concat(e),o)};function i(t,e){const o=e?"scrollTop":"scrollLeft";let s=t[e?"pageYOffset":"pageXOffset"];return"number"!=typeof s&&(s=window.document.documentElement[o]),s}function n(t,e,o,s,i,n,f,l,r,h){"boolean"!=typeof f&&(r=l,l=f,f=!1);const d="function"==typeof o?o.options:o;let a;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,i&&(d.functional=!0)),s&&(d._scopeId=s),n?(a=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,r(t)),t&&t._registeredComponents&&t._registeredComponents.add(n)},d._ssrRegister=a):e&&(a=f?function(t){e.call(this,h(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,l(t))}),a)if(d.functional){const t=d.render;d.render=function(e,o){return a.call(o),t(e,o)}}else{const t=d.beforeCreate;d.beforeCreate=t?[].concat(t,a):[a]}return o}const f={name:"BaseAffix",props:{offsetTop:{type:Number,default:0},offsetBottom:{type:Number},useCapture:{type:Boolean,default:!1}},data:()=>({affix:!1,styles:{},slot:!1,slotStyle:{}}),computed:{offsetType(){let t="top";return this.offsetBottom>=0&&(t="bottom"),t},classes(){return[{"ivu-affix":this.affix}]}},mounted(){o(window,"scroll",this.handleScroll,this.useCapture),o(window,"resize",this.handleScroll,this.useCapture),this.$nextTick((()=>{this.handleScroll()}))},beforeDestroy(){s(window,"scroll",this.handleScroll,this.useCapture),s(window,"resize",this.handleScroll,this.useCapture)},methods:{handleScroll(){const{affix:t}=this,e=i(window,!0),o=function(t){const e=t.getBoundingClientRect(),o=i(window,!0),s=i(window),n=window.document.body,f=n.clientTop||0,l=n.clientLeft||0;return{top:e.top+o-f,left:e.left+s-l}}(this.$el),s=window.innerHeight,n=this.$el.getElementsByTagName("div")[0].offsetHeight;o.top-this.offsetTop<e&&"top"===this.offsetType&&!t?(this.affix=!0,this.slotStyle={width:`${this.$refs.point.clientWidth}px`,height:`${this.$refs.point.clientHeight}px`},this.slot=!0,this.styles={top:`${this.offsetTop}px`,left:`${o.left}px`,width:`${this.$el.offsetWidth}px`},this.$emit("on-change",!0)):o.top-this.offsetTop>e&&"top"===this.offsetType&&t&&(this.slot=!1,this.slotStyle={},this.affix=!1,this.styles=null,this.$emit("on-change",!1)),o.top+this.offsetBottom+n>e+s&&"bottom"===this.offsetType&&!t?(this.affix=!0,this.styles={bottom:`${this.offsetBottom}px`,left:`${o.left}px`,width:`${this.$el.offsetWidth}px`},this.$emit("on-change",!0)):o.top+this.offsetBottom+n<e+s&&"bottom"===this.offsetType&&t&&(this.affix=!1,this.styles=null,this.$emit("on-change",!1))}}};var l=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",[o("div",{ref:"point",class:t.classes,style:t.styles},[t._t("default")],2),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:t.slot,expression:"slot"}],style:t.slotStyle})])};l._withStripped=!0;const r=n({render:l,staticRenderFns:[]},undefined,f,undefined,false,undefined,!1,void 0,void 0,void 0);module.exports=r;