diff --git a/code-blast.js b/code-blast.js index fafa9f4..4b6adda 100644 --- a/code-blast.js +++ b/code-blast.js @@ -10,6 +10,7 @@ https://twitter.com/JoelBesada/status/670343885655293952 lastTime = 0, particles = [], particlePointer = 0, + maxParticleSize = 0, MAX_PARTICLES = 500, PARTICLE_NUM_RANGE = { min: 5, max: 10 }, PARTICLE_GRAVITY = 0.08, @@ -63,13 +64,13 @@ https://twitter.com/JoelBesada/status/670343885655293952 color: color }; if (effect === 1) { - p.size = random(2, 4); + p.size = random(2, maxParticleSize || 4); p.vx = PARTICLE_VELOCITY_RANGE.x[0] + Math.random() * (PARTICLE_VELOCITY_RANGE.x[1] - PARTICLE_VELOCITY_RANGE.x[0]); p.vy = PARTICLE_VELOCITY_RANGE.y[0] + Math.random() * (PARTICLE_VELOCITY_RANGE.y[1] - PARTICLE_VELOCITY_RANGE.y[0]); } else if (effect === 2) { - p.size = random(2, 8); + p.size = random(2, maxParticleSize || 8); p.drag = 0.92; p.vx = random(-3, 3); p.vy = random(-3, 3); @@ -210,6 +211,15 @@ https://twitter.com/JoelBesada/status/670343885655293952 if (val) { codemirrors.push(editor); effect = val.effect || 2; + + if(val.shakeIntensity !== undefined) { + shakeIntensity = val.shakeIntensity; + } + + if(val.maxParticleSize !== undefined) { + maxParticleSize = val.maxParticleSize; + } + init(editor); } else { destroy(editor); diff --git a/demo/index.html b/demo/index.html index 88d1000..1f07a10 100644 --- a/demo/index.html +++ b/demo/index.html @@ -42,7 +42,11 @@ tabSize: 2, value: "
\n

Code blast plugin for Codmirror

\n
\n Based on Joel Besada's experiment:\n https://twitter.com/JoelBesada/status/670343885655293952\n
\n \n
\n\t Github: https://github.com/chinchang/code-blast-codemirror/\n
\n \n
", autoCloseTags: true, - blastCode: { effect: 2 }, + blastCode: { + effect: 2, + shakeIntensity: 2, + maxParticleSize: 4 + }, });