Skip to content

Configurable options for maximum particle size and shake intensity. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions code-blast.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
tabSize: 2,
value: "<article>\n <h1>Code blast plugin for Codmirror</h1>\n <div class=\"based-on\">\n Based on Joel Besada's experiment:\n https://twitter.com/JoelBesada/status/670343885655293952\n </div>\n \n <div>\n\t Github: https://github.com/chinchang/code-blast-codemirror/\n </div>\n \n</article>",
autoCloseTags: true,
blastCode: { effect: 2 },
blastCode: {
effect: 2,
shakeIntensity: 2,
maxParticleSize: 4
},
});
</script>

Expand Down