七夕拿什么秀技术

情话

迢迢牵牛星,皎皎河汉女。

手持弹幕

手持弹幕小程序作为一种创新的互动方式,在表达爱意方面拥有独特的魅力和效果.

效果

视觉冲击,创意表达,最主要是秀技术啊!!!

技术栈

uniApp + Vue

核心功能

组件封装

// carousel-text
<template>
 <view class="_div global_carousel_text y" v-if="!show">
  <view class="_ul" :style="fontWrapStyle">
   <view class="empty _li"></view>
   <view class="_li" :class="item.fontClass" :style="item.style"  v-for="(item, index) in textConfig" :key="index">
    {{item.font}}</view>
  </view>
 </view>
</template>

<script>
 export default {
  name: 'CarouselText',
  props: {
   text: {
    type: String,
    default: () => ('')
   },
   fontSize: {
    type: String,
    default: () => ('')
   },
   fontColor: {
    type: String,
    default: () => ('')
   },
   step: {
    type: Number,
    default: () => (0)
   },
  },
  data() {
   return {
    show: false,
    textConfig: [],
    fontWrapStyle: '',
    fontClass: '',
    loopCount: 50,
    currentStep: 400,
    timer: null
   }
  },
  watch: {
   text: function() {
    this.textHandler()
    this.setTextStyle()
   },
   step: function() {
    this.currentStep = this.step
    this.loopCount = 0
   }
  },
  mounted() {
   this.textHandler()
   this.setTextStyle()
   let t = this
   t.timer = setInterval(function() {
    t.setTextStyle()
   }, 36)
  },
  methods: {
   textHandler: function() {
    let n = []
    if (this.text) {
     for (let o = 0; o < this.text.length; o++) {
      n.push({
       font: this.text[o],
       style: "",
       fontClass: this.getTypeByText(this.text[o]) + (" " === this.text[o] ? " empty_str" : "")
      })
     }
     if (n.length > 0) {
      this.textConfig = n
      this.loopCount = 0
     
      this.$nextTick(function() {
       this.setTextStyle()
       this.show = !1
       setTimeout(function() {
        this.show = !0
       }, 400)
      })
     }
    }
   },
   setTextStyle() {
     let t = this
     if (++t.loopCount % t.currentStep == 0) {
       t.loopCount = 0
     }
   // console.log(t.textConfig, 1111111)
     t.textConfig.forEach(function(e, n) {
       let o = t.fontColor || t.getRandomColor()
       
       if (t.loopCount % 10 == 0) {
         if (t.fontColor) {
           e.style = "transition: color 0.2s;color:".concat(o, ";text-shadow: 0 0 0.5em rgba(255,255,255,.7);  ") + "font-size:" + (t.fontSize || "")
         } else {
           e.style = "transition: color 0.2s;color:rgba(255,255,255,.7);text-shadow: 0 0 0.5em ".concat(o, ";  ") + "font-size:" + (t.fontSize || "")
         }
       }
       
       t.fontWrapStyle = "top:0;transform: translate(-50%,-".concat(t.loopCount / (t.currentStep / 100), "%)")
     })
   },
   getTypeByText(t) {
       return /[\d\w]/.test(t) ? "no_zh" : "zh";
   },
   getRandomColor() {
    let t = "#" + (16777215 * Math.random() << 0).toString(16)
    return 6 === t.length && (t += 0), t
   }
  }
 }
</script>

<style>
 
</style>

功能预览

首页 菜单可隐藏

alt

自定义弹幕文字

alt

设置字体大小

alt

设置速度

alt

源码

源码在小程序搜“手持弹幕”自行获取,公众号: 牛马圈 小程序: 牛马圈分享

alt

话题

你的七夕是略过吗?

本文由 mdnice 多平台发布

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值