(function(){for(var d=0,a=["webkit","moz"],b=0;b= distanceTotal){ this.tracer.x = this.waypoints[this.tracer.waypoint][0]; this.tracer.y = this.waypoints[this.tracer.waypoint][1]; this.tracer.waypoint = (this.tracer.waypoint == this.waypoints.length - 1) ? 0 : this.tracer.waypoint + 1; } else { this.tracer.x += vx; this.tracer.y += vy; } } else { this.ctx.clearRect(0, 0, this.width, this.height); } } $elems.each(function(){ var $this = $(this); var border = $this.data('border', new Border({ elem: $this, color: $this.data('color'), speed: $this.data('speed') })); $this.data('border').loop(); }); $elems.on('mouseenter', function(){ var border = $(this).data('border'); $(border.canvas).stop(true).animate({'opacity': 1}, 400); if(!border.active){ border.active = true; border.loop(); } }); $elems.on('mouseleave', function(){ var border = $(this).data('border'); $(border.canvas).stop(true).animate({'opacity': 0}, 400, function(){ border.active = false; border.tracer.x = 0; border.tracer.y = 0; border.tracer.waypoint = 0; }); });