• JS 移动动画


       function moveElement(elementId, final_x, final_y,interval) {
                if (!document.getElementById) return false;
                if (!document.getElementById(elementId)) return false;
                var elem = document.getElementById(elementId);
                var elementLeft = parseInt(elem.style.left);
                var elementTop = parseInt(elem.style.top);
                if (elementLeft == final_x && elementTop == final_y) {
                    return true;
                }
                if (elementLeft < final_x) {
                    elementLeft++;
                }
                if (elementLeft > final_x) {
                    elementLeft--;
                }
                if (elementTop < final_y) {
                    elementTop++ ;
                }
                if (elementTop > final_y) {
                    elementTop--;
                }
                elem.style.left = elementLeft + 'px';
                elem.style.top = elementTop + 'px';
                var repeat = "moveElement('"+ elementId + "'," + final_x + "," + final_y + "," + interval + ")";
                movement = setTimeout(repeat, interval);
            }

       function positionMsg() {
                var elem = document.getElementById('message');
                elem.style.position = 'absolute';
                elem.style.left = '10px';
                elem.style.top = '100px';
                moveElement('message',200,500,100);
            };

  • 相关阅读:
    IDEA常用快捷键和设置
    java反射总结
    IO编程总结
    3月份主要学习
    idea中maven将jar包导入本地maven库
    hive常用命令
    CentOS7 安装图形化桌面
    vue+leaflet
    Springboot + Rabbitmq + WebSocet + vue
    VUE 中引入百度地图(vue-Baidu-Map)
  • 原文地址:https://www.cnblogs.com/isylar/p/4748410.html
Copyright © 2020-2023  润新知