UNPKG

@beeapi/nutui

Version:

一套轻量级移动端Vue组件库

7 lines 4.91 kB
/*! * @beeapi/nutui v2.2.10 - noticebar.js, 451ed2404bee284b891e, Sat Dec 19 2020 12:06:10 GMT+0800 (中国标准时间) * (c) 2017-2020 JDC * Released under the MIT License. */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("noticebar",[],e):"object"==typeof exports?exports.noticebar=e():t.noticebar=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="./",n(n.s=162)}({0:function(t,e,n){"use strict";function o(t,e,n,o,i,r,a,s){var c,l="function"==typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=n,l._compiled=!0),o&&(l.functional=!0),r&&(l._scopeId="data-v-"+r),a?(c=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__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},l._ssrRegister=c):i&&(c=s?function(){i.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:i),c)if(l.functional){l._injectStyles=c;var u=l.render;l.render=function(t,e){return c.call(e),u(t,e)}}else{var d=l.beforeCreate;l.beforeCreate=d?[].concat(d,c):[c]}return{exports:t,options:l}}n.d(e,"a",(function(){return o}))},162:function(t,e,n){"use strict";n.r(e);var o={name:"nut-noticebar",props:{text:{type:String,default:""},closeMode:{type:Boolean,default:!1},wrapable:{type:Boolean,default:!1},leftIcon:{type:String,default:""},color:{type:String,default:"#F9911B"},background:{type:String,default:"rgba(254,250,216,1)"},delay:{type:[String,Number],default:1},scrollable:{type:Boolean,default:!0},speed:{type:Number,default:50}},data:function(){return{wrapWidth:0,firstRound:!0,duration:0,offsetWidth:0,showNoticeBar:!0,animationClass:""}},computed:{iconShow:function(){return"close"!=this.leftIcon},barStyle:function(){return{color:this.color,background:this.background}},contentStyle:function(){return{paddingLeft:this.firstRound?0:this.wrapWidth+"px",animationDelay:(this.firstRound?this.delay:0)+"s",animationDuration:this.duration+"s"}},iconBg:function(){var t=null;return this.leftIcon&&(t=this.leftIcon),t}},watch:{text:{handler:function(t,e){var n=this;0!=this.showNoticeBar&&this.$nextTick((function(){var t=n.$refs,e=t.wrap,o=t.content;if(e&&o){var i=e.getBoundingClientRect().width,r=o.getBoundingClientRect().width;n.scrollable&&r>i?(n.wrapWidth=i,n.offsetWidth=r,n.duration=r/n.speed,n.animationClass="play"):n.animationClass=""}}))},immediate:!0}},methods:{handleClick:function(t){this.$emit("click",t)},onClickIcon:function(t){this.showNoticeBar=!this.closeMode,this.$emit("close",t)},onAnimationEnd:function(){var t=this;this.firstRound=!1,this.$nextTick((function(){t.duration=(t.offsetWidth+t.wrapWidth)/t.speed,t.animationClass="play-infinite"}))}}},i=n(0),r=Object(i.a)(o,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{directives:[{name:"show",rawName:"v-show",value:t.showNoticeBar,expression:"showNoticeBar"}],staticClass:"nut-noticebar",class:{withicon:t.closeMode,close:t.closeMode,wrapable:t.wrapable},style:t.barStyle,on:{click:t.handleClick}},[t.iconShow?n("div",{staticClass:"left-icon",style:{"background-image":"url("+t.iconBg+")"}},[t.iconBg?t._e():n("nut-icon",{attrs:{type:"notice",color:t.color,size:"16px"}})],1):t._e(),t._v(" "),n("div",{ref:"wrap",staticClass:"wrap"},[n("div",{ref:"content",staticClass:"content",class:[t.animationClass,{"nut-ellipsis":!t.scrollable&&!t.wrapable}],style:t.contentStyle,on:{animationend:t.onAnimationEnd,webkitAnimationEnd:t.onAnimationEnd}},[t._t("default",[t._v(t._s(t.text))])],2)]),t._v(" "),t.closeMode?n("div",{staticClass:"right-icon",on:{click:function(e){return e.stopPropagation(),t.onClickIcon(e)}}},[n("nut-icon",{attrs:{type:"cross",color:t.color,size:"11px"}})],1):t._e()])}),[],!1,null,null,null).exports;n(88);r.install=function(t){t.component(r.name,r)};e.default=r},88:function(t,e,n){}})})); //# sourceMappingURL=noticebar.js.map