Vue-drag-resize 拖拽缩放插件的使用(简单示例)
更新时间:2019年12月04日 09:55:01 作者:是我啊i
本文通过代码给大家介绍了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:
自定义字体在
总结
以上所述是小编给大家介绍的Vue-drag-resize 拖拽缩放插件的使用,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
相关文章
vue+video.js视频播放、视频切换、视频断点分段上传功能
本次需求是做一个视频列表,点击视频列表播放对应视频;同时要求实现断点分段上传大文件(视频)的功能,今天通过本文给大家讲解下vue+video.js视频播放、视频切换、视频断点分段上传功能,感兴趣的朋友一起看看吧2022-12-12
vue2+element-ui+nodejs实现图片上传和修改图片到数据库的方法
在Web开发中经常需要使用图片,有时候需要对图片进行上传,这篇文章主要给大家介绍了关于vue2+element-ui+nodejs实现图片上传和修改图片到数据库的相关资料,文中通过代码介绍的非常详细,需要的朋友可以参考下2024-04-04
如何基于uniapp开发android播放webrtc流详解
这篇文章主要介绍了在uniapp中播放RTSP和WebRTC协议流的区别,以及如何封装WebrtcVideo组件和音视频实时通讯的实现,文中通过代码介绍的非常详细,需要的朋友可以参考下2025-02-02
vue+element-ui JYAdmin后台管理系统模板解析
这篇文章主要介绍了vue+element-ui JYAdmin后台管理系统模板解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2020-07-07
Vuejs使用addEventListener的事件如何触发执行函数的this
这篇文章主要介绍了Vuejs使用addEventListener的事件触发执行函数的this方法,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2022-06-06


最新评论