text-scroll
Version:
## Project setup ``` npm install ```
3 lines (2 loc) • 4.64 kB
JavaScript
/* eslint-disable */ (function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["textScroll"]=e():t["textScroll"]=e()})("undefined"!==typeof self?self:this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s="fb15")}({f6fd:function(t,e){(function(t){var e="currentScript",r=t.getElementsByTagName("script");e in t||Object.defineProperty(t,e,{get:function(){try{throw new Error}catch(n){var t,e=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(n.stack)||[!1])[1];for(t in r)if(r[t].src==e||"interactive"==r[t].readyState)return r[t];return null}}})})(document)},fb15:function(t,e,r){"use strict";var n;(r.r(e),"undefined"!==typeof window)&&(r("f6fd"),(n=window.document.currentScript)&&(n=n.src.match(/(.+\/)[^\/]+\.js(\?.*)?$/))&&(r.p=n[1]));var i=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{ref:"textScroll",staticClass:"TextScroll",style:t.textScrollStyle},[r("div",{staticClass:"TextScroll-wrapper",style:t.wrapperStyle},[t._l(t.textGroup,function(e,n){return r("div",{key:n,staticClass:"TextScroll-item",style:t.itemStyle},[t._v(t._s(e))])}),r("div",{staticClass:"TextScroll-item",style:t.itemStyle},[t._v(t._s(t.textGroup[0]))])],2)])},o=[],s={name:"TextScroll",props:{width:{type:[Number,String],default:"100%"},height:{type:[Number,String],default:"36"},letterSpacing:{type:[Number,String],default:0},background:{type:String},color:{type:String},textAlign:{type:String,default:"left"},textGroup:{type:Array,default:()=>["暂无内容"]},textStyle:{type:Object,default:()=>({})},timeout:{type:[Number,String],default:2e3},animationTime:{type:[Number,String],default:800}},watch:{textIndex(t){this.moveToLast=!1,0===t&&setTimeout(()=>{this.moveToLast=!0},this.animationTime+100)}},computed:{textScrollStyle(){return{width:-1!==this.width.indexOf("%")?this.width:`${this.width}px`,height:-1!==this.height.indexOf("%")?this.height:`${this.height}px`,background:this.background,color:this.color,textAlign:"center",overflow:"hidden",borderRadius:"5px"}},itemStyle(){return Object.assign({},this.textStyle,{width:"100%",lineHeight:`${this.height}px`,letterSpacing:`${this.letterSpacing}px`})},wrapperStyle(){return this.moveToLast?{position:"relative",marginTop:0,transition:"none"}:{position:"relative",marginTop:`-${this.wrapperMarginTop}px`,transition:`all ${this.animationTimeFormat}s`}},wrapperMarginTop(){return 0===this.textIndex?this.textGroup.length*this.height:this.textIndex*this.height},animationTimeFormat(){return(this.animationTime/1e3).toFixed(1)}},data(){return{moveToLast:!0,textIndex:0,timer:null}},methods:{animation(){this.textGroup.length>1&&(this.timer=setInterval(()=>{this.textIndex=(this.textIndex+1)%this.textGroup.length},this.timeout))}},mounted(){this.animation()},destroyed(){clearInterval(this.timer)}},a=s;function l(t,e,r,n,i,o,s,a){var l,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=r,u._compiled=!0),n&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),s?(l=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},u._ssrRegister=l):i&&(l=a?function(){i.call(this,this.$root.$options.shadowRoot)}:i),l)if(u.functional){u._injectStyles=l;var c=u.render;u.render=function(t,e){return l.call(e),c(t,e)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,l):[l]}return{exports:t,options:u}}var u=l(a,i,o,!1,null,"78f12b57",null),c=u.exports;c.install=(t=>{t.component("text-scroll",c)});var d=c;e["default"]=d}})});
//# sourceMappingURL=textScroll.umd.min.js.map