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


Posted in Javascript onDecember 04, 2019

字幕

<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:

自定义字体在

总结

以上所述是小编给大家介绍的Vue-drag-resize 拖拽缩放插件的使用,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对三水点靠木网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

Javascript 相关文章推荐
用js格式化金额可设置保留的小数位数
May 09 Javascript
Javascript基础教程之switch语句
Jan 18 Javascript
javascript数据结构之双链表插入排序实例详解
Nov 25 Javascript
基于javascript实现tab切换特效
Mar 29 Javascript
jQuery validate验证插件使用详解
May 11 Javascript
vue自定义指令实现v-tap插件
Nov 03 Javascript
纯js实现倒计时功能
Jan 06 Javascript
详解在 Angular 项目中添加 clean-blog 模板
Jul 04 Javascript
ES7中利用Await减少回调嵌套的方法详解
Nov 01 Javascript
JavaScript函数、闭包、原型、面向对象学习笔记
Sep 06 Javascript
微信小程序实现单选功能
Oct 30 Javascript
更优雅的微信小程序骨架屏实现详解
Aug 07 Javascript
jQuery实现全选、反选和不选功能的方法详解
Dec 04 #jQuery
JavaScript中如何对多维数组(矩阵)去重的实现
Dec 04 #Javascript
Vue实现base64编码图片间的切换功能
Dec 04 #Javascript
Vue实现点击当前元素以外的地方隐藏当前元素(实现思路)
Dec 04 #Javascript
Vue实现图片与文字混输效果
Dec 04 #Javascript
环形加载进度条封装(Vue插件版和原生js版)
Dec 04 #Javascript
element-ui 远程搜索组件el-select在项目中组件化的实现代码
Dec 04 #Javascript
You might like
php中json_encode UTF-8中文乱码的更好解决方法
2014/09/28 PHP
跟我学Laravel之请求(Request)的生命周期
2014/10/15 PHP
详解PHP中的PDO类
2015/07/06 PHP
php+redis实现商城秒杀功能
2020/11/19 PHP
用jquery中插件dialog实现弹框效果实例代码
2013/11/15 Javascript
nodeJs爬虫获取数据简单实现代码
2016/03/29 NodeJs
javascript 闭包详解及简单实例应用
2016/12/31 Javascript
基于JavaScript实现验证码功能
2017/04/01 Javascript
Angular 4依赖注入学习教程之组件服务注入(二)
2017/06/04 Javascript
浅谈ECMAScript6新特性之let、const
2017/08/02 Javascript
帝国cms首页列表页实现点赞功能
2017/10/30 Javascript
使用vue官方提供的模板vue-cli搭建一个helloWorld案例分析
2018/01/16 Javascript
vue获取当前激活路由的方法
2018/03/17 Javascript
JS 实现分页打印功能
2018/05/16 Javascript
[06:09]辉夜杯主赛事开幕式
2015/12/25 DOTA
低版本中Python除法运算小技巧
2015/04/05 Python
python实现多线程抓取知乎用户
2016/12/12 Python
一个基于flask的web应用诞生 用户注册功能开发(5)
2017/04/11 Python
python学习教程之Numpy和Pandas的使用
2017/09/11 Python
Django实现分页功能
2018/07/02 Python
对python中数组的del,remove,pop区别详解
2018/11/07 Python
Ubuntu权限不足无法创建文件夹解决方案
2020/11/14 Python
细说NumPy数组的四种乘法的使用
2020/12/18 Python
python 获取谷歌浏览器保存的密码
2021/01/06 Python
html5 Canvas画图教程(6)—canvas里画曲线之arcTo方法
2013/01/09 HTML / CSS
Linux如何为某个操作添加别名
2013/03/01 面试题
海量信息软件测试笔试题
2015/08/08 面试题
校园达人秀策划书
2014/01/12 职场文书
八项规定自查自纠报告及整改措施
2014/10/26 职场文书
入党政审材料范文
2014/12/24 职场文书
婚礼答谢礼品
2015/01/20 职场文书
高中生社会实践心得体会
2016/01/14 职场文书
公司晚会主持词
2019/04/17 职场文书
制定企业培训计划的五大要点!
2019/07/10 职场文书
请学会珍惜眼前,因为人生没有下辈子!
2019/11/12 职场文书
《弟子规》读后感:知廉耻、明是非、懂荣辱、辨善恶
2019/12/03 职场文书