/** * Created by bcxin on 2016/12/13. */ if (!Function.prototype.bind) { Function.prototype.bind = function(oThis) { if (typeof this !== "function") { throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); } var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function() {}, fBound = function() { return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); }; fNOP.prototype = this.prototype; fBound.prototype = new fNOP(); return fBound; }; } var adv={ DISTANCE:0,//�ܾ��� DURATION:1000,//��ʱ�� STEPS:500,//�ܲ��� step:0,//���� interval:0,//ÿ��ʱ���� timer:null,//���涨ʱ�����? moved:0,//�����Ѿ��ƶ��IJ��� div:null,//������div WAIT:3000,//����ȴ�ʱ��? init:function(){ this.div=$(".msg")[0]; $(this.div).css("display","block"); this.DISTANCE=-parseFloat($(this.div).css("bottom")); this.interval=this.DURATION/this.STEPS; this.step=this.DISTANCE/this.STEPS; this.moveUp(); }, moveUp:function(){//�������� this.timer=setInterval(this.moveStep.bind(this),this.interval); }, moveStep:function(){// �����ƶ�һ�� var bottom=parseFloat($(this.div).css("bottom"));// ��ȡ this.div.style.bottom=bottom+this.step+"px"; this.moved++; if(this.moved==this.STEPS){ clearInterval(this.timer); this.timer=null; this.moved=0; } }, moveDown:function(){ if(this.timer==null){ $(this.div).fadeOut(500).css("bottom",-140+"px"); } }, upView:function(title,data,url){ $(".msg .content h4").html(title); $(".msg .content span").html(data); $(".msg .look-deatil a").attr("href",url); } } setInterval(function(){ var bottom=parseFloat($(".msg").css("bottom")); if(bottom!=0&&bottom==-140) { adv.upView("这是标题","这是内容!","auth/register/init"); adv.init(); } },300000000);