1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > js实现div拖动动画运行轨迹效果代码分享【javascript】

js实现div拖动动画运行轨迹效果代码分享【javascript】

时间:2018-11-01 11:14:06

相关推荐

js实现div拖动动画运行轨迹效果代码分享【javascript】

web前端|js教程

js托动div,js实现div拖动,js鼠标拖动div

web前端-js教程

本文实例讲述了js div拖动动画运行轨迹效果。分享给大家供大家参考。具体如下:

这是一款基于js实现的div拖动动画运行轨迹效果源码,是一款原生js div拖动效果制作鼠标拖动div动画运行轨迹效果代码。可以选择【记住轨迹】与【不记住轨迹】两种拖动显示模式,从而显示出不同的拖动效果。

运行效果图: ——————-查看效果 下载源码——————-

报修管理系统源码,vscode设置字体颜色插件,ubuntu 扫描,tomcat 集群 组播,sqlite opc,网页设计图片环绕着动起来的代码,轻云服务器经济版 数据库,免费企业邮箱服务器,wordpress图床插件,前端逻辑框架,吹气爬虫,php要学什么,黄聪seo,springboot静态版,标签卡特效,网站vr模板,asp手机网页制作,简单购物网页模板中文版免费下载,ztouch官网后台,asp 页面联动 无刷新,学生选课管理系统java web,java制作小程序lzw

电子招投标源码,vscode阅读模式,ubuntu ipa,tomcat每周宕机,sqlite3 run,织梦在线聊天插件,前端三大框架哪个最难,页面爬虫的实验总结,curl php 参数,更合seo优化服务,网站模版上线需要什么意思,网页背景图拉伸,微信视频网站模板lzw

小提示:浏览器中如果不能正常运行,可以尝试切换浏览模式。

为大家分享的js div拖动动画运行轨迹效果代码如下

种子解析网页源码,如何查ubuntu端口,tomcat项目启动全过程,python爬虫按钮下载,php留言簿页面设计,余杭seo方案lzw

js div拖动动画运行轨迹效果代码 - 脚本之家*{margin:0px;padding:0px;}#div1{position:relative;left:200px;top:200px;width:100px; height:100px; background-color:#f60;cursor:move;}var isIE = (document.all)?true:false;var $ID = function(id){ return "string"==typeof id?document.getElementById(id):id;}var Class = { create:function(){ return function(){ this.initilize.apply(this,arguments); } }}var Extend = function(destination, source){ for(var property in source){ destination[property] = source[property]; }}var Bind = function(object,fun){ var args = Array.prototype.slice.call(arguments).slice(2); return function(){ return fun.apply(object,args); }}var BindAsEventListener = function(object,fun){ var args = Array.prototype.slice.call(arguments).slice(2); return function(event){ return fun.apply(object,[event||window.event].concat(args)); }}function addEventHandler(oTarget, sEventType, fnHandler) { if (oTarget.addEventListener) { oTarget.addEventListener(sEventType, fnHandler, false); } else if (oTarget.attachEvent) { oTarget.attachEvent("on" + sEventType, fnHandler); } else { oTarget["on" + sEventType] = fnHandler; }};function removeEventHandler(oTarget, sEventType, fnHandler) { if (oTarget.removeEventListener) { oTarget.removeEventListener(sEventType, fnHandler, false); } else if (oTarget.detachEvent) { oTarget.detachEvent("on" + sEventType, fnHandler); } else { oTarget["on" + sEventType] = null; }};function getNodePosition(node,type){//type="left"or"top" var nodeTemp = node; var l = 0; var t = 0; while(nodeTemp!=document.body&&nodeTemp!=null){ l += nodeTemp.offsetLeft; t += nodeTemp.offsetTop; nodeTemp = nodeTemp.offsetParent; } if(type.toLowerCase()=="left") return l; else return t;}//前面通常都用一个base.js封装var MyDrag = Class.create();MyDrag.prototype = { initilize:function(obj){ this.Obj = $ID(obj); this._x = this._y = 0; this._xx = this._yy = 0;//Move记录坐标 this.Obj.style.position = "absolute"; this._pos = []; this._ifSavePos = true; this._t = null; this._speed = 10; this._indexMove = 0;//全局的MoveIndex this._fnStart = BindAsEventListener(this,this.Start); this._fnMove = BindAsEventListener(this,this.Move); this._fnStop = Bind(this,this.Stop); addEventHandler(this.Obj,"mousedown",this._fnStart); }, Start:function(oEvent){ if(!this._ifSavePos) this._pos = []; this.Drag = this.Obj.cloneNode(true); if(isIE) this.Drag.style.filter = "alpha(opacity=50)"; else this.Drag.style.opacity = "0.5"; this.Obj.parentNode.appendChild(this.Drag); this._left1 = this._xx = getNodePosition(this.Obj,"left"); this._top1 = this._yy = getNodePosition(this.Obj,"top"); this._x = oEvent.clientX - this.Obj.offsetLeft; this._y = oEvent.clientY - this.Obj.offsetTop; addEventHandler(document,"mousemove",this._fnMove); addEventHandler(document,"mouseup",this._fnStop); this._t = setInterval(Bind(this,this.SavePos),10); }, SavePos:function(){//记录坐标点 this._pos.push(this._xx + "_" + this._yy); }, Move:function(oEvent){ if(isIE) oEvent.returnValue = false; this._xx = oEvent.clientX - this._x; this._yy = oEvent.clientY - this._y; this.Drag.style.left = this._xx + "px"; this.Drag.style.top = this._yy + "px"; }, Stop:function(){ removeEventHandler(document,"mousemove",this._fnMove); removeEventHandler(document,"mouseup",this._fnStop); this.Obj.parentNode.removeChild(this.Drag); this.Obj.style.left = this._xx + "px"; this.Obj.style.top = this._yy + "px"; clearInterval(this._t); this._fnCloneMove = Bind(this,this.CloneMove); this._t = setTimeout(this._fnCloneMove,50); }, CloneMove:function(){ if(this._indexMove=this.options.pos.length){ this.options.pos = []; document.body.removeChild(this.Obj); clearInterval(this._t); }else{ this.Obj.style.left = this.options.pos[this._indexMove].split("_")[0] + "px"; this.Obj.style.top = this.options.pos[this._indexMove].split("_")[1] + "px"; } this._indexMove++; }}onload = function(){ var myDrag = new MyDrag("div1"); $ID("rad1").onclick = function(){ myDrag._ifSavePos = true; } $ID("rad2").onclick = function(){ myDrag._ifSavePos = false; }}

随意拖动那个小方块几秒钟

适用浏览器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗.

来源:脚本之家

以上就是为大家分享的jQuery UI设置固定日期选择代码,希望大家可以喜欢。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。