From 209a1f7347a6ed4c3e26a7ea79dc7001249fbae1 Mon Sep 17 00:00:00 2001 From: Sahithyen Kanaganayagam Date: Thu, 1 Oct 2015 19:50:46 +0200 Subject: [PATCH 1/2] Changed code according JSLint - Solved all warnings JSLint outputs - Consistent code style --- jquery.particleground.js | 129 ++++++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 50 deletions(-) diff --git a/jquery.particleground.js b/jquery.particleground.js index 3146625..b8a8001 100644 --- a/jquery.particleground.js +++ b/jquery.particleground.js @@ -17,18 +17,24 @@ out = out || {}; for (var i = 1; i < arguments.length; i++) { var obj = arguments[i]; - if (!obj) continue; + + if (!obj) { + continue; + } + for (var key in obj) { if (obj.hasOwnProperty(key)) { - if (typeof obj[key] === 'object') + if (typeof obj[key] === 'object') { deepExtend(out[key], obj[key]); - else + } else { out[key] = obj[key]; + } } } } + return out; - }; + } var $ = window.jQuery; @@ -56,9 +62,11 @@ * Init */ function init() { - if (!canvasSupport) { return; } + if (!canvasSupport) { + return; + } - //Create canvas + // Create canvas canvas = document.createElement('canvas'); canvas.className = 'pg-canvas'; canvas.style.display = 'block'; @@ -72,7 +80,7 @@ var p = new Particle(); p.setStackPos(i); particles.push(p); - }; + } window.addEventListener('resize', function() { resizeHandler(); @@ -84,7 +92,7 @@ }, false); if (orientationSupport && !desktop) { - window.addEventListener('deviceorientation', function () { + window.addEventListener('deviceorientation', function() { // Contrain tilt range to [-30,30] tiltY = Math.min(Math.max(-event.beta, -30), 30); tiltX = Math.min(Math.max(-event.gamma, -30), 30); @@ -110,7 +118,9 @@ * Draw particles */ function draw() { - if (!canvasSupport) { return; } + if (!canvasSupport) { + return; + } winW = window.innerWidth; winH = window.innerHeight; @@ -121,11 +131,12 @@ // Update particle positions for (var i = 0; i < particles.length; i++) { particles[i].updatePosition(); - }; + } + // Draw particles - for (var i = 0; i < particles.length; i++) { + for (i = 0; i < particles.length; i++) { particles[i].draw(); - }; + } // Call this function next time screen is redrawn if (!paused) { @@ -148,7 +159,7 @@ if (particles[i].position.x > elWidth || particles[i].position.y > elHeight) { particles.splice(i, 1); } - }; + } // Adjust particle density var numParticles = Math.round((canvas.width * canvas.height) / options.density); @@ -164,7 +175,7 @@ // Re-index particles for (i = particles.length - 1; i >= 0; i--) { particles[i].setStackPos(i); - }; + } } /** @@ -186,37 +197,44 @@ * Particle */ function Particle() { - this.stackPos; + this.stackPos = null; this.active = true; this.layer = Math.ceil(Math.random() * 3); this.parallaxOffsetX = 0; this.parallaxOffsetY = 0; + // Initial particle position this.position = { x: Math.ceil(Math.random() * canvas.width), y: Math.ceil(Math.random() * canvas.height) } // Random particle speed, within min and max values - this.speed = {} + this.speed = {}; + switch (options.directionX) { case 'left': this.speed.x = +(-options.maxSpeedX + (Math.random() * options.maxSpeedX) - options.minSpeedX).toFixed(2); break; + case 'right': this.speed.x = +((Math.random() * options.maxSpeedX) + options.minSpeedX).toFixed(2); break; + default: this.speed.x = +((-options.maxSpeedX / 2) + (Math.random() * options.maxSpeedX)).toFixed(2); this.speed.x += this.speed.x > 0 ? options.minSpeedX : -options.minSpeedX; break; } + switch (options.directionY) { case 'up': this.speed.y = +(-options.maxSpeedY + (Math.random() * options.maxSpeedY) - options.minSpeedY).toFixed(2); break; + case 'down': this.speed.y = +((Math.random() * options.maxSpeedY) + options.minSpeedY).toFixed(2); break; + default: this.speed.y = +((-options.maxSpeedY / 2) + (Math.random() * options.maxSpeedY)).toFixed(2); this.speed.x += this.speed.y > 0 ? options.minSpeedY : -options.minSpeedY; @@ -236,13 +254,14 @@ // Draw lines ctx.beginPath(); + // Iterate over all particles which are higher in the stack than this one for (var i = particles.length - 1; i > this.stackPos; i--) { var p2 = particles[i]; // Pythagorus theorum to get distance between two points - var a = this.position.x - p2.position.x - var b = this.position.y - p2.position.y + var a = this.position.x - p2.position.x; + var b = this.position.y - p2.position.y; var dist = Math.sqrt((a * a) + (b * b)).toFixed(2); // If the two particles are in proximity, join them @@ -255,9 +274,10 @@ } } } + ctx.stroke(); ctx.closePath(); - } + }; /** * update particle position @@ -265,16 +285,16 @@ Particle.prototype.updatePosition = function() { if (options.parallax) { if (orientationSupport && !desktop) { - // Map tiltX range [-30,30] to range [0,winW] - var ratioX = (winW - 0) / (30 - -30); - pointerX = (tiltX - -30) * ratioX + 0; - // Map tiltY range [-30,30] to range [0,winH] - var ratioY = (winH - 0) / (30 - -30); - pointerY = (tiltY - -30) * ratioY + 0; + var ratioX = winW / 60; + pointerX = (tiltX + 30) * ratioX; + + var ratioY = winH / 60; + pointerY = (tiltY + 30) * ratioY; } else { pointerX = mouseX; pointerY = mouseY; } + // Calculate parallax offsets this.parallaxTargX = (pointerX - (winW / 2)) / (options.parallaxMultiplier * this.layer); this.parallaxOffsetX += (this.parallaxTargX - this.parallaxOffsetX) / 10; // Easing equation @@ -291,11 +311,13 @@ this.position.x = elWidth - this.parallaxOffsetX; } break; + case 'right': if (this.position.x + this.speed.x + this.parallaxOffsetX > elWidth) { this.position.x = 0 - this.parallaxOffsetX; } break; + default: // If particle has reached edge of canvas, reverse its direction if (this.position.x + this.speed.x + this.parallaxOffsetX > elWidth || this.position.x + this.speed.x + this.parallaxOffsetX < 0) { @@ -310,11 +332,13 @@ this.position.y = elHeight - this.parallaxOffsetY; } break; + case 'down': if (this.position.y + this.speed.y + this.parallaxOffsetY > elHeight) { this.position.y = 0 - this.parallaxOffsetY; } break; + default: // If particle has reached edge of canvas, reverse its direction if (this.position.y + this.speed.y + this.parallaxOffsetY > elHeight || this.position.y + this.speed.y + this.parallaxOffsetY < 0) { @@ -326,16 +350,16 @@ // Move particle this.position.x += this.speed.x; this.position.y += this.speed.y; - } + }; /** * Setter: particle stacking position */ Particle.prototype.setStackPos = function(i) { this.stackPos = i; - } + }; - function option (key, val) { + function option(key, val) { if (val) { options[key] = val; } else { @@ -399,12 +423,14 @@ var methodName = arguments[0]; var args = Array.prototype.slice.call(arguments, 1); var returnVal; + this.each(function() { if ($.data(this, 'plugin_' + pluginName) && typeof $.data(this, 'plugin_' + pluginName)[methodName] === 'function') { returnVal = $.data(this, 'plugin_' + pluginName)[methodName].apply(this, args); } }); - if (returnVal !== undefined){ + + if (returnVal !== undefined) { return returnVal; } else { return this; @@ -428,26 +454,29 @@ * @license: MIT license */ (function() { - var lastTime = 0; - var vendors = ['ms', 'moz', 'webkit', 'o']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] - || window[vendors[x]+'CancelRequestAnimationFrame']; - } + var lastTime = 0; + var vendors = ['ms', 'moz', 'webkit', 'o']; + for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { + window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; + window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || + window[vendors[x] + 'CancelRequestAnimationFrame']; + } + + if (!window.requestAnimationFrame) + window.requestAnimationFrame = function(callback, element) { + var currTime = new Date().getTime(); + var timeToCall = Math.max(0, 16 - (currTime - lastTime)); + var id = window.setTimeout(function() { + callback(currTime + timeToCall); + }, + timeToCall); + lastTime = currTime + timeToCall; + return id; + }; - if (!window.requestAnimationFrame) - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - - if (!window.cancelAnimationFrame) - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; + if (!window.cancelAnimationFrame) { + window.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; + } }()); From 1aea2e36b97ca939d18f03e9d3bdde229b11569d Mon Sep 17 00:00:00 2001 From: Sahithyen Kanaganayagam Date: Thu, 1 Oct 2015 20:14:05 +0200 Subject: [PATCH 2/2] Added support for High DPI Displays Added support for High DPI Displays --- jquery.particleground.js | 55 +++++++++++++++++++++++------------- jquery.particleground.min.js | 4 +-- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/jquery.particleground.js b/jquery.particleground.js index b8a8001..1383cd6 100644 --- a/jquery.particleground.js +++ b/jquery.particleground.js @@ -48,6 +48,8 @@ var mouseY = 0; var winW; var winH; + var elW; + var elH; var desktop = !navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|mobi|tablet|opera mini|nexus 7)/i); var orientationSupport = !!window.DeviceOrientationEvent; var tiltX = 0; @@ -75,7 +77,7 @@ styleCanvas(); // Create particles - var numParticles = Math.round((canvas.width * canvas.height) / options.density); + var numParticles = Math.round((elW * elH) / options.density); for (var i = 0; i < numParticles; i++) { var p = new Particle(); p.setStackPos(i); @@ -107,8 +109,26 @@ * Style the canvas */ function styleCanvas() { - canvas.width = element.offsetWidth; - canvas.height = element.offsetHeight; + elW = element.offsetWidth; + elH = element.offsetHeight; + + var devicePixelRatio = window.devicePixelRatio || 1; + var backingStoreRatio = ctx.webkitBackingStorePixelRatio || + ctx.mozBackingStorePixelRatio || + ctx.msBackingStorePixelRatio || + ctx.oBackingStorePixelRatio || + ctx.backingStorePixelRatio || 1; + + var ratio = devicePixelRatio / backingStoreRatio; + + canvas.width = elW * ratio; + canvas.height = elH * ratio; + + canvas.style.width = elW + 'px'; + canvas.style.height = elH + 'px'; + + ctx.scale(ratio, ratio); + ctx.fillStyle = options.dotColor; ctx.strokeStyle = options.lineColor; ctx.lineWidth = options.lineWidth; @@ -151,18 +171,15 @@ // Resize the canvas styleCanvas(); - var elWidth = element.offsetWidth; - var elHeight = element.offsetHeight; - // Remove particles that are outside the canvas for (var i = particles.length - 1; i >= 0; i--) { - if (particles[i].position.x > elWidth || particles[i].position.y > elHeight) { + if (particles[i].position.x > elW || particles[i].position.y > elH) { particles.splice(i, 1); } } // Adjust particle density - var numParticles = Math.round((canvas.width * canvas.height) / options.density); + var numParticles = Math.round((elW * elH) / options.density); if (numParticles > particles.length) { while (numParticles > particles.length) { var p = new Particle(); @@ -205,9 +222,10 @@ // Initial particle position this.position = { - x: Math.ceil(Math.random() * canvas.width), - y: Math.ceil(Math.random() * canvas.height) - } + x: Math.ceil(Math.random() * elW), + y: Math.ceil(Math.random() * elH) + }; + // Random particle speed, within min and max values this.speed = {}; @@ -302,25 +320,22 @@ this.parallaxOffsetY += (this.parallaxTargY - this.parallaxOffsetY) / 10; // Easing equation } - var elWidth = element.offsetWidth; - var elHeight = element.offsetHeight; - switch (options.directionX) { case 'left': if (this.position.x + this.speed.x + this.parallaxOffsetX < 0) { - this.position.x = elWidth - this.parallaxOffsetX; + this.position.x = elW - this.parallaxOffsetX; } break; case 'right': - if (this.position.x + this.speed.x + this.parallaxOffsetX > elWidth) { + if (this.position.x + this.speed.x + this.parallaxOffsetX > elW) { this.position.x = 0 - this.parallaxOffsetX; } break; default: // If particle has reached edge of canvas, reverse its direction - if (this.position.x + this.speed.x + this.parallaxOffsetX > elWidth || this.position.x + this.speed.x + this.parallaxOffsetX < 0) { + if (this.position.x + this.speed.x + this.parallaxOffsetX > elW || this.position.x + this.speed.x + this.parallaxOffsetX < 0) { this.speed.x = -this.speed.x; } break; @@ -329,19 +344,19 @@ switch (options.directionY) { case 'up': if (this.position.y + this.speed.y + this.parallaxOffsetY < 0) { - this.position.y = elHeight - this.parallaxOffsetY; + this.position.y = elH - this.parallaxOffsetY; } break; case 'down': - if (this.position.y + this.speed.y + this.parallaxOffsetY > elHeight) { + if (this.position.y + this.speed.y + this.parallaxOffsetY > elH) { this.position.y = 0 - this.parallaxOffsetY; } break; default: // If particle has reached edge of canvas, reverse its direction - if (this.position.y + this.speed.y + this.parallaxOffsetY > elHeight || this.position.y + this.speed.y + this.parallaxOffsetY < 0) { + if (this.position.y + this.speed.y + this.parallaxOffsetY > elH || this.position.y + this.speed.y + this.parallaxOffsetY < 0) { this.speed.y = -this.speed.y; } break; diff --git a/jquery.particleground.min.js b/jquery.particleground.min.js index dca1f0b..789c47b 100644 --- a/jquery.particleground.min.js +++ b/jquery.particleground.min.js @@ -7,10 +7,10 @@ * * Inspired by http://requestlab.fr/ and http://disruptivebydesign.com/ */ -!function(a,b){"use strict";function c(a){a=a||{};for(var b=1;be;e++){var f=new n;f.setStackPos(e),z.push(f)}a.addEventListener("resize",function(){k()},!1),b.addEventListener("mousemove",function(a){A=a.pageX,B=a.pageY},!1),D&&!C&&a.addEventListener("deviceorientation",function(){F=Math.min(Math.max(-event.beta,-30),30),E=Math.min(Math.max(-event.gamma,-30),30)},!0),j(),q("onInit")}}function i(){r.width=d.offsetWidth,r.height=d.offsetHeight,s.fillStyle=g.dotColor,s.strokeStyle=g.lineColor,s.lineWidth=g.lineWidth}function j(){if(y){u=a.innerWidth,v=a.innerHeight,s.clearRect(0,0,r.width,r.height);for(var b=0;b=0;c--)(z[c].position.x>a||z[c].position.y>b)&&z.splice(c,1);var e=Math.round(r.width*r.height/g.density);if(e>z.length)for(;e>z.length;){var f=new n;z.push(f)}else e=0;c--)z[c].setStackPos(c)}function l(){G=!0}function m(){G=!1,j()}function n(){switch(this.stackPos,this.active=!0,this.layer=Math.ceil(3*Math.random()),this.parallaxOffsetX=0,this.parallaxOffsetY=0,this.position={x:Math.ceil(Math.random()*r.width),y:Math.ceil(Math.random()*r.height)},this.speed={},g.directionX){case"left":this.speed.x=+(-g.maxSpeedX+Math.random()*g.maxSpeedX-g.minSpeedX).toFixed(2);break;case"right":this.speed.x=+(Math.random()*g.maxSpeedX+g.minSpeedX).toFixed(2);break;default:this.speed.x=+(-g.maxSpeedX/2+Math.random()*g.maxSpeedX).toFixed(2),this.speed.x+=this.speed.x>0?g.minSpeedX:-g.minSpeedX}switch(g.directionY){case"up":this.speed.y=+(-g.maxSpeedY+Math.random()*g.maxSpeedY-g.minSpeedY).toFixed(2);break;case"down":this.speed.y=+(Math.random()*g.maxSpeedY+g.minSpeedY).toFixed(2);break;default:this.speed.y=+(-g.maxSpeedY/2+Math.random()*g.maxSpeedY).toFixed(2),this.speed.x+=this.speed.y>0?g.minSpeedY:-g.minSpeedY}}function o(a,b){return b?void(g[a]=b):g[a]}function p(){console.log("destroy"),r.parentNode.removeChild(r),q("onDestroy"),f&&f(d).removeData("plugin_"+e)}function q(a){void 0!==g[a]&&g[a].call(d)}var r,s,t,u,v,w,x,y=!!b.createElement("canvas").getContext,z=[],A=0,B=0,C=!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|mobi|tablet|opera mini|nexus 7)/i),D=!!a.DeviceOrientationEvent,E=0,F=0,G=!1;return g=c({},a[e].defaults,g),n.prototype.draw=function(){s.beginPath(),s.arc(this.position.x+this.parallaxOffsetX,this.position.y+this.parallaxOffsetY,g.particleRadius/2,0,2*Math.PI,!0),s.closePath(),s.fill(),s.beginPath();for(var a=z.length-1;a>this.stackPos;a--){var b=z[a],c=this.position.x-b.position.x,d=this.position.y-b.position.y,e=Math.sqrt(c*c+d*d).toFixed(2);ec&&(this.position.x=0-this.parallaxOffsetX);break;default:(this.position.x+this.speed.x+this.parallaxOffsetX>c||this.position.x+this.speed.x+this.parallaxOffsetX<0)&&(this.speed.x=-this.speed.x)}switch(g.directionY){case"up":this.position.y+this.speed.y+this.parallaxOffsetY<0&&(this.position.y=e-this.parallaxOffsetY);break;case"down":this.position.y+this.speed.y+this.parallaxOffsetY>e&&(this.position.y=0-this.parallaxOffsetY);break;default:(this.position.y+this.speed.y+this.parallaxOffsetY>e||this.position.y+this.speed.y+this.parallaxOffsetY<0)&&(this.speed.y=-this.speed.y)}this.position.x+=this.speed.x,this.position.y+=this.speed.y},n.prototype.setStackPos=function(a){this.stackPos=a},h(),{option:o,destroy:p,start:m,pause:l}}var e="particleground",f=a.jQuery;a[e]=function(a,b){return new d(a,b)},a[e].defaults={minSpeedX:.1,maxSpeedX:.7,minSpeedY:.1,maxSpeedY:.7,directionX:"center",directionY:"center",density:1e4,dotColor:"#666666",lineColor:"#666666",particleRadius:7,lineWidth:1,curvedLines:!1,proximity:100,parallax:!0,parallaxMultiplier:5,onInit:function(){},onDestroy:function(){}},f&&(f.fn[e]=function(a){if("string"==typeof arguments[0]){var b,c=arguments[0],g=Array.prototype.slice.call(arguments,1);return this.each(function(){f.data(this,"plugin_"+e)&&"function"==typeof f.data(this,"plugin_"+e)[c]&&(b=f.data(this,"plugin_"+e)[c].apply(this,g))}),void 0!==b?b:this}return"object"!=typeof a&&a?void 0:this.each(function(){f.data(this,"plugin_"+e)||f.data(this,"plugin_"+e,new d(this,a))})})}(window,document),/** +!function(t,e){"use strict";function i(t){t=t||{};for(var e=1;en;n++){var s=new c;s.setStackPos(n),b.push(s)}t.addEventListener("resize",function(){h()},!1),e.addEventListener("mousemove",function(t){F=t.pageX,A=t.pageY},!1),R&&!C&&t.addEventListener("deviceorientation",function(){q=Math.min(Math.max(-event.beta,-30),30),T=Math.min(Math.max(-event.gamma,-30),30)},!0),p(),m("onInit")}}function l(){X=a.offsetWidth,Y=a.offsetHeight;var e=t.devicePixelRatio||1,i=g.webkitBackingStorePixelRatio||g.mozBackingStorePixelRatio||g.msBackingStorePixelRatio||g.oBackingStorePixelRatio||g.backingStorePixelRatio||1;O=e/i,y.width=X*O,y.height=Y*O,y.style.width=X+"px",y.style.height=Y+"px",g.scale(O,O),g.fillStyle=o.dotColor,g.strokeStyle=o.lineColor,g.lineWidth=o.lineWidth}function p(){if(P){w=t.innerWidth,S=t.innerHeight,g.clearRect(0,0,y.width,y.height);for(var e=0;e=0;t--)(b[t].position.x>X||b[t].position.y>Y)&&b.splice(t,1);var e=Math.round(X*Y/o.density);if(e>b.length)for(;e>b.length;){var i=new c;b.push(i)}else e=0;t--)b[t].setStackPos(t)}function d(){B=!0}function f(){B=!1,p()}function c(){switch(this.stackPos=null,this.active=!0,this.layer=Math.ceil(3*Math.random()),this.parallaxOffsetX=0,this.parallaxOffsetY=0,this.position={x:Math.ceil(Math.random()*X),y:Math.ceil(Math.random()*Y)},this.speed={},o.directionX){case"left":this.speed.x=+(-o.maxSpeedX+Math.random()*o.maxSpeedX-o.minSpeedX).toFixed(2);break;case"right":this.speed.x=+(Math.random()*o.maxSpeedX+o.minSpeedX).toFixed(2);break;default:this.speed.x=+(-o.maxSpeedX/2+Math.random()*o.maxSpeedX).toFixed(2),this.speed.x+=this.speed.x>0?o.minSpeedX:-o.minSpeedX}switch(o.directionY){case"up":this.speed.y=+(-o.maxSpeedY+Math.random()*o.maxSpeedY-o.minSpeedY).toFixed(2);break;case"down":this.speed.y=+(Math.random()*o.maxSpeedY+o.minSpeedY).toFixed(2);break;default:this.speed.y=+(-o.maxSpeedY/2+Math.random()*o.maxSpeedY).toFixed(2),this.speed.x+=this.speed.y>0?o.minSpeedY:-o.minSpeedY}}function x(t,e){return e?void(o[t]=e):o[t]}function u(){console.log("destroy"),y.parentNode.removeChild(y),m("onDestroy"),s&&s(a).removeData("plugin_"+n)}function m(t){void 0!==o[t]&&o[t].call(a)}var y,g,v,w,S,X,Y,O,M,k,P=!!e.createElement("canvas").getContext,b=[],F=0,A=0,C=!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|mobi|tablet|opera mini|nexus 7)/i),R=!!t.DeviceOrientationEvent,T=0,q=0,B=!1;return o=i({},t[n].defaults,o),c.prototype.draw=function(){g.beginPath(),g.arc(this.position.x+this.parallaxOffsetX,this.position.y+this.parallaxOffsetY,o.particleRadius/2,0,2*Math.PI,!0),g.closePath(),g.fill(),g.beginPath();for(var t=b.length-1;t>this.stackPos;t--){var e=b[t],i=this.position.x-e.position.x,a=this.position.y-e.position.y,n=Math.sqrt(i*i+a*a).toFixed(2);nX&&(this.position.x=0-this.parallaxOffsetX);break;default:(this.position.x+this.speed.x+this.parallaxOffsetX>X||this.position.x+this.speed.x+this.parallaxOffsetX<0)&&(this.speed.x=-this.speed.x)}switch(o.directionY){case"up":this.position.y+this.speed.y+this.parallaxOffsetY<0&&(this.position.y=Y-this.parallaxOffsetY);break;case"down":this.position.y+this.speed.y+this.parallaxOffsetY>Y&&(this.position.y=0-this.parallaxOffsetY);break;default:(this.position.y+this.speed.y+this.parallaxOffsetY>Y||this.position.y+this.speed.y+this.parallaxOffsetY<0)&&(this.speed.y=-this.speed.y)}this.position.x+=this.speed.x,this.position.y+=this.speed.y},c.prototype.setStackPos=function(t){this.stackPos=t},r(),{option:x,destroy:u,start:f,pause:d}}var n="particleground",s=t.jQuery;t[n]=function(t,e){return new a(t,e)},t[n].defaults={minSpeedX:.1,maxSpeedX:.7,minSpeedY:.1,maxSpeedY:.7,directionX:"center",directionY:"center",density:1e4,dotColor:"#666666",lineColor:"#666666",particleRadius:7,lineWidth:1,curvedLines:!1,proximity:100,parallax:!0,parallaxMultiplier:5,onInit:function(){},onDestroy:function(){}},s&&(s.fn[n]=function(t){if("string"==typeof arguments[0]){var e,i=arguments[0],o=Array.prototype.slice.call(arguments,1);return this.each(function(){s.data(this,"plugin_"+n)&&"function"==typeof s.data(this,"plugin_"+n)[i]&&(e=s.data(this,"plugin_"+n)[i].apply(this,o))}),void 0!==e?e:this}return"object"!=typeof t&&t?void 0:this.each(function(){s.data(this,"plugin_"+n)||s.data(this,"plugin_"+n,new a(this,t))})})}(window,document),/** * requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel * @see: http://paulirish.com/2011/requestanimationframe-for-smart-animating/ * @see: http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating * @license: MIT license */ -function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c