参考:

https://blog.csdn.net/leijie0322/article/details/80664554

https://www.cnblogs.com/jpfss/p/9106209.html

需求是要求在图片上添加一个动画效果,可以位置、颜色、大小等参数,

1、在原有的图片上增加一个动画层、

2、动态更换动画参数

3、删除之前加载的动画,更新动画。

      <div
v-else
@mousedown="move"
@touchstart="phonetouchstart"
@touchmove="phonetouchmove"
@touchend="phonetouchend"
align="justify"
class="img3dmodels"
>
<img id="floormodels" :src="img_url" />
<div id="animation_div"></div> //这里就是动画层了 </div>

添加div

    setanimationparameter(op, parameter) {
// 创建动画var divs = document.createElement("div") // 创建div
var cass = document.createAttribute("class"); //创建class定义
cass.value = "animation"; //添加class
divs.setAttributeNode(cass) //div绑定class
var style = document.createAttribute("style"); // 创建style
divs.setAttributeNode(style); // 绑定style divs.style.width = parameter.w;
divs.style.height = parameter.h;
divs.style.left = parameter.x;
divs.style.top = parameter.y;
divs.style.backgroundColor = parameter.color;
op.appendChild(divs) // 添加到动画层 },

清空div

    removeanimation(){
//清空动画、清空动画层内所有的元素
let op = document.getElementById("animation_div");
op.innerHTML =''
},

执行代码

setanimation(parameter,imgIndex) {
let op = document.getElementById("animation_div");
this.removeanimation()
// 楼栋名称、底图、位置、大小、形状、显示隐藏
// parameter : 动画参数
// imgIndex : 展示底图名称
// console.log(parameter)
this.img_url = `${this.imgpwd}${this.filename}${this.prefix}${imgIndex}.png`; if(parameter){
if (parameter.length){
for (let index = 0; index < parameter.length; index++) {
const element = parameter[index];
this.setanimationparameter(op,element);
}
}else{
this.setanimationparameter(op,parameter);
}
console.log("更换动画");
}else{
console.log('动画参数为空')
} },

最新文章

  1. JavaScript——exec和match
  2. Enum:Game of Lines(POJ 3668)
  3. iOS 关于objectForKey返回类型是不是mutable
  4. Networking with PHP
  5. HtmlWeb类
  6. [WinForm] 使用反射将业务对象绑定到窗体或控件容器
  7. java 日志技术汇总(log4j , Commons-logging,.....)
  8. ios使用openUrl进行应用跳转
  9. JDK5-枚举
  10. gnu make
  11. ural1671 Anansi&#39;s Cobweb
  12. Shell命令-文件及内容处理之wc,tr
  13. css3之border-radius理解
  14. VO和DO转换(四) MapStruct
  15. Vue--的src文件
  16. 找出程序GasMileage中的哪一行与下列叙述相对应:
  17. Java基本知识进阶
  18. Jmeter-连接 MySQL数据库
  19. Eclipse出现An error has occurred,See error log for more details的错误
  20. 一道面试题:用shell写一个从1加到100的程序

热门文章

  1. 内存吞金兽(Elasticsearch)的那些事儿 -- 认识一下
  2. SpringCloud War 包部署导致服务未正常注册到 Nacos 问题
  3. 流媒体 Ubuntu部署srs、windows部署nginx
  4. spring的异常处理
  5. 理解Flink中的Task和SUBTASK
  6. final 关键字,你想知道的都在这里
  7. Python中的文件处理和数据存储json
  8. vue js 手写 正则判断 手机号码 和 密码
  9. 学习Linux tar 命令:最简单也最困难
  10. noip模拟42