首页
网站首页
公司简介
资讯中心
推荐内容
返回顶部
一个简单的js动画效果代码_javascript技巧_脚本之家
发布时间:2019-12-25 16:28
浏览次数:

实现的功能:移动,暂停,恢复,停止. 未实现的功能:无法实现单位换算,不能实现颜色渐变 代码中的使用方法如下: 复制代码 代码如下: var $m = $M; _.onclick = function(){ this.disabled = true; var that = this; $m.animate({left:"300px",top:"100px",width:"300px", height:"200px",opacity:0.3},{duration:5000,easing:Tween.Back.easeInOut}).delay .animate({left:"50px",top:"300px",width:"150px",height:"100px",opacity:0.8},{duration:2000,easing:Tween.Elastic.easeInOut, callback:function(){ that.disabled = false; } }); } _.onclick = function; this.disabled = true; _.disabled = false; } _.disabled = true; _.onclick = function; this.disabled = true; _.disabled = false; } _.onclick = function; _.disabled = false; } 功能实现: 复制代码 代码如下: /* 简单动画方法 * 未实现单位换算 */ var $M = function{ var elem = ("string" === typeof obj )?document.getElementById:obj; var _this = {},props = {},timeId,isBusy = false,isPause = false; var queue = [],_current; //直线运动算法 function Linear{ return c*t/d + b;} function setCss{ if(className == "opacity"){ if{ elem.style["opacity"] = value; } else { elem.style["filter"] = 'alpha(opacity=' + 100 * value + ')'; } } else { elem.style[className] = value; } } function getCss{ if(className == "opacity"){ var ret = ""; if{ ret = document.defaultView.getComputedStyle['opacity'] || 1; } else { ret = elem.currentStyle['filter']?(elem.currentStyle['filter'].match(/^alpha$/))[1]一个简单的js动画效果代码_javascript技巧_脚本之家。/100 : 1; } return ret.toString(); } else { return elem.style[className].toString(); } } function _move(params,easing,st,ht,callback){ var t = .getTime; _current.t = t; if{return;} easing = easing||Linear; ht = ht || 500; for{ if{ var iv = parseFloat || 0; var ev = parseFloat; props[p] = { iv:iv, iu:iv?getCss.substring:null, ev:ev, eu:params[p].toString().substring } //TODO } if{t = ht;} var nv = easing(t,props[p].iv,(props[p].ev - props[p].iv),ht); nv = parseFloat; setCss; } if{ timeId = setTimeout{ _move(params,easing,st,ht,callback); },13); } else { props = {}; isBusy = false; if; } run{ if(!isBusy && queue.length != 0){ var o = queue.shift(); var _delay = 0; while{ _delay += o.delay; o = queue.shift{ _current = o; isBusy = true; setTimeout{ var st = ; _move(o.params,o.options.easing,st,o.options.duration,o.options.callback); },_delay); } } } var _this = { animate:function{ queue.push({params:params,options:options}); isPause = false; run(); return _this; }, delay:function{ queue.push; return _this; }, pause:function(){ isPause = true; return _this; }, resume:function{ var o = _current; isPause = false; var st = - _current.t; _move(o.params,o.options.easing,st,o.options.duration,o.options.callback); return _this; } }, stop:function(){ isPause = true; isBusy = false; queue = []; props = {}; return _this; } }; return _this; } 参考地址://www.jb51.net/article/24309.htm

复制代码 代码如下: var SDelegate = function { this.asFunction_ = function() { return f.apply; } } else { this.asFunction_ = function() { return f.apply; } } this.method_ = f; this.binding_ = b; this.continus = c; } SDelegate.composite = function { var con = d.continus.composited_ = SDelegate.composite; var method = d.asFunction_; return function() { con.apply; return method.apply; } } else { return d.asFunction_; } } SDelegate.prototype.call = function() { if this.composited_ = SDelegate.composite; return this.composited_.apply(arguments[0], Array.prototype.slice.call; } SDelegate.prototype.remove = function() { var removeP = function(parent, item, test, data) { if return; parent.composited_ = item.composited_ = null; if { parent.continus = item.continus; removeP(parent, item.continus, test, data); } else { removeP(item, item.continus, test, data); } }; return function { var p = this; if { p = this.continus; } removeP(p, p.continus, test, data); p.composited_ = null; return p; } }(); SDelegate.prototype.append = function { return new SDelegate; } 这个SDelegate用起来可能会比较诡异,比如很多操作都要重新赋值。Dess中,SDelegate主要用于一些特定场合,如DOM事件派发。

复制代码 代码如下:

如题所示,返回unix时间戳所对应的具体时间: 复制代码 代码如下: var time = '1278927966'; // 关键在乘1000,因为时间是相对于1970年开始的,所以乘1000后将会转到当前时间。 var real_time = new Date * 1000; document.write; 代码很简单就完成时间戳的转换。

友情链接: 网站地图
Copyright © 2015-2019 http://www.nflfreepicks.net. 新葡萄京娱乐场网址有限公司 版权所有