Vue-drag-resize 拖拽缩放插件使用简单示例

字幕

<div id="lBox" style="background-color: #D7E9F5;"
                 :style="{'height': parentHeight + 'px', 'width': parentWidth + 'px'}">
                 
	<drag-resize v-for="(rect,index) in texts"
                           style="overflow: hidden;"
                           :w="rect.BoxWidth"
                           :h="rect.BoxHeight"
                           :x="rect.BoxLeft"
                           :y="rect.BoxTop"
                           @resizing="textResize($event, index)" 
                           @dragging="textResize($event, index)">
                           
		<div style="width: 100%; height: 100%;"
				:style={backgroundColor:rect.BoxColor,opacity:rect.BoxOpacity}>
		</div><!-- 控制背景色及背景透明度 使背景透明度不影响字幕 -->
                
		<div style="width: 100%; height: 100%;">
                <p :class="rect.Direction === 'Left to Right' ? 'roll-right' : 'roll-left'"
                     style="width: 100%; position:absolute; bottom:-0.25em;left:0px"
                     :style="{color: rect.TextColor,fontFamily: rect.FontFile,
                    fontSize: rect.FontSize+'px',
                    opacity:rect.FontOpacity,
                    animationDuration: rect.Speed + 's'}">
                    {{rect.Text}}
                </p>
		</div>
		
	</drag-resize>

logo

	<drag-resize v-for="(rect,index) in logos"
                       :parentLimitation="true"
                       :w="rect.Width"
                       :h="rect.Height"
                       :x="rect.Left"
                       :y="rect.Top"
                       @resizing="logoResize($event, index)" 
                       @dragging="logoResize($event, index)">
                           
                <div style="width: 100%;height: 100%;">
                  	<img :src="'/logos/' + rect.FileName"
                       	style="width: 100%;height: 100%;">
                </div>
                
	</drag-resize>
</div>

JS

	textResize(newRect, index) {
        const BoxWidth = newRect.width+''
        this.texts[index].BoxWidth = BoxWidth.substring(0, BoxWidth.indexOf("."))

        const BoxHeight = newRect.height+''
        this.texts[index].BoxHeight = BoxHeight.substring(0, BoxHeight.indexOf("."))

        const BoxTop = newRect.top+''
        this.texts[index].BoxTop = BoxTop.substring(0, BoxTop.indexOf("."))

        const BoxLeft = newRect.left+''
        this.texts[index].BoxLeft = BoxLeft.substring(0, BoxLeft.indexOf("."))
	}
	logoResize(newRect, index) {
        const Width = newRect.width''
        this.logos[index].Width = Width.substring(0, Size.indexOf("."))
        
        const Height = newRect.height+''
        this.logos[index].Height = Height .substring(0, Size.indexOf("."))
        
        const Top = newRect.top+''
        this.logos[index].Top = Top.substring(0, Top.indexOf("."))

        const Left = newRect.left+''
        this.logos[index].Left = Left.substring(0, Left.indexOf("."))
	}

除此之外还有字幕向左或向右滚动的CSS

  .roll-left {
    animation: wordsLoopLeft 6s linear infinite normal;
  }

  .roll-right {
    animation: wordsLoopRight 6s linear infinite normal;
  }

  @keyframes wordsLoopLeft {
    0% {
      transform: translateX(100%);
      -webkit-transform: translateX(100%);
    }
    100% {
      transform: translateX(-40%);
      -webkit-transform: translateX(-40%);
    }
  }

  @keyframes wordsLoopRight {
    0% {
      transform: translateX(-40%);
      -webkit-transform: translateX(-40%);
    }
    100% {
      transform: translateX(100%);
      -webkit-transform: translateX(100%);
    }
  }

And:
自定义字体在
CSS @font-face 自定义字体

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值