From 03148c48c7614502c754f67e30d466ec30bd1c35 Mon Sep 17 00:00:00 2001 From: Jayde-Im Date: Thu, 11 May 2017 12:04:47 +0900 Subject: [PATCH 1/3] [Add] shakeIntensity and maxParticleSize options --- code-blast.js | 12 +++++++++++- demo/index.html | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/code-blast.js b/code-blast.js index fafa9f4..1f474f8 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 = 8, MAX_PARTICLES = 500, PARTICLE_NUM_RANGE = { min: 5, max: 10 }, PARTICLE_GRAVITY = 0.08, @@ -69,7 +70,7 @@ https://twitter.com/JoelBesada/status/670343885655293952 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); 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) { + shakeIntensity = val.shakeIntensity; + } + + if(val.maxParticleSize) { + 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 + }, }); From 7d03d983775d2f0883bebe72058ddbbee4d8b674 Mon Sep 17 00:00:00 2001 From: Jayde-Im Date: Thu, 11 May 2017 16:11:45 +0900 Subject: [PATCH 2/3] [Bug Fix] Set zero value options --- code-blast.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code-blast.js b/code-blast.js index 1f474f8..d447c3c 100644 --- a/code-blast.js +++ b/code-blast.js @@ -212,11 +212,11 @@ https://twitter.com/JoelBesada/status/670343885655293952 codemirrors.push(editor); effect = val.effect || 2; - if(val.shakeIntensity) { + if(val.shakeIntensity !== undefined) { shakeIntensity = val.shakeIntensity; } - if(val.maxParticleSize) { + if(val.maxParticleSize !== undefined) { maxParticleSize = val.maxParticleSize; } From b0b70b60221a9237f459ed97110fa30ec134be2d Mon Sep 17 00:00:00 2001 From: Jayde-Im Date: Fri, 23 Jun 2017 14:58:53 +0900 Subject: [PATCH 3/3] [Add] Configurable maxParticleSize on effect 1 --- code-blast.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code-blast.js b/code-blast.js index d447c3c..4b6adda 100644 --- a/code-blast.js +++ b/code-blast.js @@ -10,7 +10,7 @@ https://twitter.com/JoelBesada/status/670343885655293952 lastTime = 0, particles = [], particlePointer = 0, - maxParticleSize = 8, + maxParticleSize = 0, MAX_PARTICLES = 500, PARTICLE_NUM_RANGE = { min: 5, max: 10 }, PARTICLE_GRAVITY = 0.08, @@ -64,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, maxParticleSize); + p.size = random(2, maxParticleSize || 8); p.drag = 0.92; p.vx = random(-3, 3); p.vy = random(-3, 3);